A Discrete-Event Network Simulator
API
udp-client-server-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  */
21 #include "ns3/udp-server.h"
22 #include "ns3/udp-client.h"
23 #include "ns3/udp-trace-client.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 
27 namespace ns3 {
28 
30 {
32 }
33 
35 {
37  SetAttribute ("Port", UintegerValue (port));
38 }
39 
40 void
41 UdpServerHelper::SetAttribute (std::string name, const AttributeValue &value)
42 {
43  m_factory.Set (name, value);
44 }
45 
48 {
50  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
51  {
52  Ptr<Node> node = *i;
53 
55  node->AddApplication (m_server);
56  apps.Add (m_server);
57 
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 (NodeContainer::Iterator 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 (NodeContainer::Iterator 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
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:157
Ptr< UdpServer > m_server
The last created server application.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Hold variables of type string.
Definition: string.h:41
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:68
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
UdpClientHelper()
Create UdpClientHelper which will make life easier for people trying to set up simulations with udp-c...
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
ObjectFactory m_factory
Object factory.
ApplicationContainer Install(NodeContainer c)
ApplicationContainer Install(NodeContainer c)
uint16_t port
Definition: dsdv-manet.cc:45
a polymophic address class
Definition: address.h:90
UdpServerHelper()
Create UdpServerHelper which will make life easier for people trying to set up simulations with udp-c...
UdpTraceClientHelper()
Create UdpTraceClientHelper which will make life easier for people trying to set up simulations with ...
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< UdpServer > GetServer(void)
Return the last created server.
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-client.cc:43
static TypeId GetTypeId(void)
Get the type ID.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
address
Definition: first.py:37
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
A Udp client.
Definition: udp-client.h:43
Default trace to send.
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-server.cc:45
AttributeValue implementation for Address.
Definition: address.h:278
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
A UDP server, receives UDP packets from a remote host.
Definition: udp-server.h:48