5G-LENA nr-v4.0
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
traffic-generator-helper.cc
1// Copyright (c) 2008 INRIA
2// Copyright (c) 2023 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3//
4// SPDX-License-Identifier: GPL-2.0-only
5
6#include "traffic-generator-helper.h"
7
8#include "ns3/inet-socket-address.h"
9#include "ns3/names.h"
10#include "ns3/packet-socket-address.h"
11#include "ns3/string.h"
12
13namespace ns3
14{
15
17 Address address,
18 TypeId ftpTypeId)
19{
20 m_factory.SetTypeId(ftpTypeId);
21 m_factory.Set("Protocol", StringValue(protocol));
22 m_factory.Set("Remote", AddressValue(address));
23}
24
25void
26TrafficGeneratorHelper::SetAttribute(std::string name, const AttributeValue& value)
27{
28 m_factory.Set(name, value);
29}
30
31ApplicationContainer
33{
34 return ApplicationContainer(InstallPriv(node));
35}
36
37ApplicationContainer
38TrafficGeneratorHelper::Install(std::string nodeName) const
39{
40 Ptr<Node> node = Names::Find<Node>(nodeName);
41 return ApplicationContainer(InstallPriv(node));
42}
43
44ApplicationContainer
45TrafficGeneratorHelper::Install(NodeContainer c) const
46{
47 ApplicationContainer apps;
48 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
49 {
50 apps.Add(InstallPriv(*i));
51 }
52
53 return apps;
54}
55
56Ptr<Application>
57TrafficGeneratorHelper::InstallPriv(Ptr<Node> node) const
58{
59 Ptr<Application> app = m_factory.Create<Application>();
60 node->AddApplication(app);
61
62 return app;
63}
64
65} // namespace ns3
TrafficGeneratorHelper(std::string protocol, Address address, TypeId ftpTypeId)
void SetAttribute(std::string name, const AttributeValue &value)
ApplicationContainer Install(NodeContainer c) const