A Discrete-Event Network Simulator
API
udp-client-server-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18  */
20 
21 #include "ns3/string.h"
22 #include "ns3/udp-client.h"
23 #include "ns3/udp-server.h"
24 #include "ns3/udp-trace-client.h"
25 #include "ns3/uinteger.h"
26 
27 namespace ns3
28 {
29 
31 {
33 }
34 
36 {
39 }
40 
41 void
42 UdpServerHelper::SetAttribute(std::string name, const AttributeValue& value)
43 {
44  m_factory.Set(name, value);
45 }
46 
49 {
51  for (auto i = c.Begin(); i != c.End(); ++i)
52  {
53  Ptr<Node> node = *i;
54 
56  node->AddApplication(m_server);
57  apps.Add(m_server);
58  }
59  return apps;
60 }
61 
64 {
65  return m_server;
66 }
67 
69 {
71 }
72 
74 {
76  SetAttribute("RemoteAddress", AddressValue(address));
77  SetAttribute("RemotePort", UintegerValue(port));
78 }
79 
81 {
83  SetAttribute("RemoteAddress", AddressValue(address));
84 }
85 
86 void
87 UdpClientHelper::SetAttribute(std::string name, const AttributeValue& value)
88 {
89  m_factory.Set(name, value);
90 }
91 
94 {
96  for (auto i = c.Begin(); i != c.End(); ++i)
97  {
98  Ptr<Node> node = *i;
100  node->AddApplication(client);
101  apps.Add(client);
102  }
103  return apps;
104 }
105 
107 {
109 }
110 
112 {
114  SetAttribute("RemoteAddress", AddressValue(address));
115  SetAttribute("RemotePort", UintegerValue(port));
116  SetAttribute("TraceFilename", StringValue(filename));
117 }
118 
120 {
122  SetAttribute("RemoteAddress", AddressValue(address));
123  SetAttribute("TraceFilename", StringValue(filename));
124 }
125 
126 void
127 UdpTraceClientHelper::SetAttribute(std::string name, const AttributeValue& value)
128 {
129  m_factory.Set(name, value);
130 }
131 
134 {
136  for (auto i = c.Begin(); i != c.End(); ++i)
137  {
138  Ptr<Node> node = *i;
140  node->AddApplication(client);
141  apps.Add(client);
142  }
143  return apps;
144 }
145 
146 } // namespace ns3
a polymophic address class
Definition: address.h:101
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Hold a value for an Attribute.
Definition: attribute.h:70
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:169
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Hold variables of type string.
Definition: string.h:56
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ObjectFactory m_factory
Object factory.
ApplicationContainer Install(NodeContainer c)
UdpClientHelper()
Create UdpClientHelper which will make life easier for people trying to set up simulations with udp-c...
A Udp client.
Definition: udp-client.h:45
static TypeId GetTypeId()
Get the type ID.
Definition: udp-client.cc:46
Ptr< UdpServer > m_server
The last created server application.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Ptr< UdpServer > GetServer()
Return the last created server.
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
ObjectFactory m_factory
Object factory.
UdpServerHelper()
Create UdpServerHelper which will make life easier for people trying to set up simulations with udp-c...
A UDP server, receives UDP packets from a remote host.
Definition: udp-server.h:50
static TypeId GetTypeId()
Get the type ID.
Definition: udp-server.cc:45
ApplicationContainer Install(NodeContainer c)
UdpTraceClientHelper()
Create UdpTraceClientHelper which will make life easier for people trying to set up simulations with ...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ObjectFactory m_factory
Object factory.
A trace based streamer.
static TypeId GetTypeId()
Get the type ID.
Hold an unsigned integer type.
Definition: uinteger.h:45
uint16_t port
Definition: dsdv-manet.cc:44
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.