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
26namespace ns3 {
27
29{
32}
33
34void
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
49UdpEchoServerHelper::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
89void
91 std::string name,
92 const AttributeValue &value)
93{
94 m_factory.Set (name, value);
95}
96
97void
99{
100 app->GetObject<UdpEchoClient>()->SetFill (fill);
101}
102
103void
105{
106 app->GetObject<UdpEchoClient>()->SetFill (fill, dataLength);
107}
108
109void
110UdpEchoClientHelper::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
122UdpEchoClientHelper::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
a polymophic address class
Definition: address.h:91
AttributeValue implementation for Address.
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:69
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
UdpEchoClientHelper(Address ip, uint16_t port)
Create UdpEchoClientHelper which will make life easier for people trying to set up simulations with e...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(Ptr< Node > node) const
Create a udp echo client application on the specified node.
ObjectFactory m_factory
Object factory.
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install an ns3::UdpEchoClient on the node configured with all the attributes set with SetAttribute.
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...
A Udp Echo client.
static TypeId GetTypeId(void)
Get the type ID.
UdpEchoServerHelper(uint16_t port)
Create UdpEchoServerHelper which will make life easier for people trying to set up simulations with e...
Ptr< Application > InstallPriv(Ptr< Node > node) const
Install an ns3::UdpEchoServer on the node configured with all the attributes set with SetAttribute.
ObjectFactory m_factory
Object factory.
ApplicationContainer Install(Ptr< Node > node) const
Create a UdpEchoServerApplication on the specified Node.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
A Udp Echo server.
static TypeId GetTypeId(void)
Get the type ID.
Hold an unsigned integer type.
Definition: uinteger.h:44
uint16_t port
Definition: dsdv-manet.cc:45
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.