A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
27namespace ns3
28{
29
31{
33}
34
36{
39}
40
41void
42UdpServerHelper::SetAttribute(std::string name, const AttributeValue& value)
43{
44 m_factory.Set(name, value);
45}
46
49{
51 for (NodeContainer::Iterator 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
86void
87UdpClientHelper::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
111UdpTraceClientHelper::UdpTraceClientHelper(Address address, uint16_t port, std::string filename)
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
126void
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
a polymophic address class
Definition: address.h:100
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:70
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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.
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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.