A Discrete-Event Network Simulator
API
udp-echo-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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "udp-echo-helper.h"
21 #include "ns3/udp-echo-server.h"
22 #include "ns3/udp-echo-client.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/names.h"
25 
26 namespace ns3 {
27 
29 {
31  SetAttribute ("Port", UintegerValue (port));
32 }
33 
34 void
36  std::string name,
37  const AttributeValue &value)
38 {
39  m_factory.Set (name, value);
40 }
41 
44 {
45  return ApplicationContainer (InstallPriv (node));
46 }
47 
49 UdpEchoServerHelper::Install (std::string nodeName) const
50 {
51  Ptr<Node> node = Names::Find<Node> (nodeName);
52  return ApplicationContainer (InstallPriv (node));
53 }
54 
57 {
59  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
60  {
61  apps.Add (InstallPriv (*i));
62  }
63 
64  return apps;
65 }
66 
69 {
71  node->AddApplication (app);
72 
73  return app;
74 }
75 
77 {
79  SetAttribute ("RemoteAddress", AddressValue (address));
80  SetAttribute ("RemotePort", UintegerValue (port));
81 }
82 
84 {
86  SetAttribute ("RemoteAddress", AddressValue (address));
87 }
88 
89 void
91  std::string name,
92  const AttributeValue &value)
93 {
94  m_factory.Set (name, value);
95 }
96 
97 void
99 {
100  app->GetObject<UdpEchoClient>()->SetFill (fill);
101 }
102 
103 void
104 UdpEchoClientHelper::SetFill (Ptr<Application> app, uint8_t fill, uint32_t dataLength)
105 {
106  app->GetObject<UdpEchoClient>()->SetFill (fill, dataLength);
107 }
108 
109 void
110 UdpEchoClientHelper::SetFill (Ptr<Application> app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength)
111 {
112  app->GetObject<UdpEchoClient>()->SetFill (fill, fillLength, dataLength);
113 }
114 
117 {
118  return ApplicationContainer (InstallPriv (node));
119 }
120 
122 UdpEchoClientHelper::Install (std::string nodeName) const
123 {
124  Ptr<Node> node = Names::Find<Node> (nodeName);
125  return ApplicationContainer (InstallPriv (node));
126 }
127 
130 {
132  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
133  {
134  apps.Add (InstallPriv (*i));
135  }
136 
137  return apps;
138 }
139 
142 {
144  node->AddApplication (app);
145 
146  return app;
147 }
148 
149 } // 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
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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
ApplicationContainer Install(Ptr< Node > node) const
Create a UdpEchoServerApplication on the specified Node.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
uint16_t port
Definition: dsdv-manet.cc:45
a polymophic address class
Definition: address.h:90
UdpEchoClientHelper(Address ip, uint16_t port)
Create UdpEchoClientHelper which will make life easier for people trying to set up simulations with e...
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install an ns3::UdpEchoServer on the node configured with all the attributes set with SetAttribute...
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install an ns3::UdpEchoClient on the node configured with all the attributes set with SetAttribute...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
A Udp Echo client.
void SetFill(Ptr< Application > app, std::string fill)
Given a pointer to a UdpEchoClient application, set the data fill of the packet (what is sent as data...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
ApplicationContainer Install(Ptr< Node > node) const
Create a udp echo client application on the specified node.
address
Definition: first.py:37
static TypeId GetTypeId(void)
Get the type ID.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
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.
AttributeValue implementation for Address.
Definition: address.h:278
UdpEchoServerHelper(uint16_t port)
Create UdpEchoServerHelper which will make life easier for people trying to set up simulations with e...
A Udp Echo server.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
static TypeId GetTypeId(void)
Get the type ID.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
ObjectFactory m_factory
Object factory.