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
ns3::UdpTraceClientHelper::UdpTraceClientHelper
UdpTraceClientHelper()
Create UdpTraceClientHelper which will make life easier for people trying to set up simulations with ...
Definition: udp-client-server-helper.cc:106
ns3::UdpTraceClientHelper::m_factory
ObjectFactory m_factory
Object factory.
Definition: udp-client-server-helper.h:208
ns3::UdpClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Definition: udp-client-server-helper.cc:87
ns3::UdpServerHelper::GetServer
Ptr< UdpServer > GetServer(void)
Return the last created server.
Definition: udp-client-server-helper.cc:63
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UdpClient
A Udp client.
Definition: udp-client.h:44
ns3::AddressValue
AttributeValue implementation for Address.
Definition: address.h:278
ns3::AttributeValue
Hold a value for an Attribute.
Definition: attribute.h:69
ns3::UdpTraceClient::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-trace-client.cc:62
ns3::UdpServer::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-server.cc:45
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition: application-container.cc:67
ns3::Ptr< Node >
ns3::UdpTraceClientHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition: udp-client-server-helper.cc:133
ns3::UdpServerHelper::m_server
Ptr< UdpServer > m_server
The last created server application.
Definition: udp-client-server-helper.h:84
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition: node-container.cc:77
ns3::UdpClientHelper::UdpClientHelper
UdpClientHelper()
Create UdpClientHelper which will make life easier for people trying to set up simulations with udp-c...
Definition: udp-client-server-helper.cc:68
ns3::Node::AddApplication
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:159
ns3::UdpServerHelper::UdpServerHelper
UdpServerHelper()
Create UdpServerHelper which will make life easier for people trying to set up simulations with udp-c...
Definition: udp-client-server-helper.cc:29
first.address
address
Definition: first.py:44
ns3::UdpTraceClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Definition: udp-client-server-helper.cc:127
ns3::UdpServerHelper::m_factory
ObjectFactory m_factory
Object factory.
Definition: udp-client-server-helper.h:83
ns3::UdpServerHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Definition: udp-client-server-helper.cc:41
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition: node-container.h:42
ns3::UdpTraceClient
Default trace to send.
Definition: udp-trace-client.cc:48
ns3::UdpClient::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: udp-client.cc:43
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition: application-container.h:43
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition: object-factory.h:223
ns3::UdpClientHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition: udp-client-server-helper.cc:93
ns3::UdpServerHelper::Install
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
Definition: udp-client-server-helper.cc:47
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition: node-container.cc:82
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition: object-factory.cc:40
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Definition: object-factory.cc:98
ns3::UdpServer
A UDP server, receives UDP packets from a remote host.
Definition: udp-server.h:49
udp-client-server-helper.h
ns3::UdpClientHelper::m_factory
ObjectFactory m_factory
Object factory.
Definition: udp-client-server-helper.h:144
port
uint16_t port
Definition: dsdv-manet.cc:45