A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
*/
20
#include "
udp-client-server-helper.h
"
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
29
UdpServerHelper::UdpServerHelper
()
30
{
31
}
32
33
UdpServerHelper::UdpServerHelper
(uint16_t
port
)
34
{
35
m_factory
.
SetTypeId
(
UdpServer::GetTypeId
());
36
SetAttribute
(
"Port"
,
UintegerValue
(port));
37
}
38
39
void
40
UdpServerHelper::SetAttribute
(std::string name,
const
AttributeValue
&value)
41
{
42
m_factory
.
Set
(name, value);
43
}
44
45
ApplicationContainer
46
UdpServerHelper::Install
(
NodeContainer
c)
47
{
48
ApplicationContainer
apps;
49
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
50
{
51
Ptr<Node>
node = *i;
52
53
m_server
=
m_factory
.
Create
<
UdpServer
> ();
54
node->
AddApplication
(
m_server
);
55
apps.
Add
(
m_server
);
56
57
}
58
return
apps;
59
}
60
61
Ptr<UdpServer>
62
UdpServerHelper::GetServer
(
void
)
63
{
64
return
m_server
;
65
}
66
67
UdpClientHelper::UdpClientHelper
()
68
{
69
}
70
71
UdpClientHelper::UdpClientHelper
(
Address
address
, uint16_t
port
)
72
{
73
m_factory
.
SetTypeId
(
UdpClient::GetTypeId
());
74
SetAttribute
(
"RemoteAddress"
,
AddressValue
(address));
75
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
76
}
77
78
UdpClientHelper::UdpClientHelper
(
Ipv4Address
address
, uint16_t
port
)
79
{
80
m_factory
.
SetTypeId
(
UdpClient::GetTypeId
());
81
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
82
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
83
}
84
85
UdpClientHelper::UdpClientHelper
(
Ipv6Address
address
, uint16_t
port
)
86
{
87
m_factory
.
SetTypeId
(
UdpClient::GetTypeId
());
88
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
89
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
90
}
91
92
void
93
UdpClientHelper::SetAttribute
(std::string name,
const
AttributeValue
&value)
94
{
95
m_factory
.
Set
(name, value);
96
}
97
98
ApplicationContainer
99
UdpClientHelper::Install
(
NodeContainer
c)
100
{
101
ApplicationContainer
apps;
102
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
103
{
104
Ptr<Node>
node = *i;
105
Ptr<UdpClient>
client =
m_factory
.
Create
<
UdpClient
> ();
106
node->
AddApplication
(client);
107
apps.
Add
(client);
108
}
109
return
apps;
110
}
111
112
UdpTraceClientHelper::UdpTraceClientHelper
()
113
{
114
}
115
116
UdpTraceClientHelper::UdpTraceClientHelper
(
Address
address
, uint16_t
port
, std::string filename)
117
{
118
m_factory
.
SetTypeId
(
UdpTraceClient::GetTypeId
());
119
SetAttribute
(
"RemoteAddress"
,
AddressValue
(address));
120
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
121
SetAttribute
(
"TraceFilename"
,
StringValue
(filename));
122
}
123
124
UdpTraceClientHelper::UdpTraceClientHelper
(
Ipv4Address
address
, uint16_t
port
, std::string filename)
125
{
126
m_factory
.
SetTypeId
(
UdpTraceClient::GetTypeId
());
127
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
128
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
129
SetAttribute
(
"TraceFilename"
,
StringValue
(filename));
130
}
131
132
UdpTraceClientHelper::UdpTraceClientHelper
(
Ipv6Address
address
, uint16_t
port
, std::string filename)
133
{
134
m_factory
.
SetTypeId
(
UdpTraceClient::GetTypeId
());
135
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
136
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
137
SetAttribute
(
"TraceFilename"
,
StringValue
(filename));
138
}
139
140
void
141
UdpTraceClientHelper::SetAttribute
(std::string name,
const
AttributeValue
&value)
142
{
143
m_factory
.
Set
(name, value);
144
}
145
146
ApplicationContainer
147
UdpTraceClientHelper::Install
(
NodeContainer
c)
148
{
149
ApplicationContainer
apps;
150
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
151
{
152
Ptr<Node>
node = *i;
153
Ptr<UdpTraceClient>
client =
m_factory
.
Create
<
UdpTraceClient
> ();
154
node->
AddApplication
(client);
155
apps.
Add
(client);
156
}
157
return
apps;
158
}
159
160
}
// namespace ns3
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition:
application-container.h:41
ns3::Node::AddApplication
uint32_t AddApplication(Ptr< Application > application)
Definition:
node.cc:146
ns3::UdpServerHelper::m_server
Ptr< UdpServer > m_server
Definition:
udp-client-server-helper.h:75
ns3::Ptr< Node >
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Definition:
node-container.h:41
ns3::StringValue
hold variables of type string
Definition:
string.h:19
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
Definition:
application-container.cc:64
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::UdpTraceClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Definition:
udp-client-server-helper.cc:141
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:40
ns3::UdpClientHelper::UdpClientHelper
UdpClientHelper()
Definition:
udp-client-server-helper.cc:67
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:77
ns3::UdpServerHelper::m_factory
ObjectFactory m_factory
Definition:
udp-client-server-helper.h:74
ns3::UdpTraceClientHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition:
udp-client-server-helper.cc:147
ns3::UdpClientHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition:
udp-client-server-helper.cc:99
port
uint16_t port
Definition:
dsdv-manet.cc:44
ns3::Address
a polymophic address class
Definition:
address.h:86
ns3::UdpServerHelper::UdpServerHelper
UdpServerHelper()
Definition:
udp-client-server-helper.cc:29
ns3::UdpTraceClientHelper::UdpTraceClientHelper
UdpTraceClientHelper()
Definition:
udp-client-server-helper.cc:112
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:89
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:46
ns3::UdpTraceClientHelper::m_factory
ObjectFactory m_factory
Definition:
udp-client-server-helper.h:177
ns3::UdpServerHelper::GetServer
Ptr< UdpServer > GetServer(void)
Definition:
udp-client-server-helper.cc:62
ns3::UdpClient::GetTypeId
static TypeId GetTypeId(void)
Definition:
udp-client.cc:42
ns3::UdpTraceClient::GetTypeId
static TypeId GetTypeId(void)
Definition:
udp-trace-client.cc:57
ns3::UdpClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Definition:
udp-client-server-helper.cc:93
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:38
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition:
node-container.cc:72
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:58
ns3::UdpClient
A Udp client. Sends UDP packet carrying sequence number and time stamp in their payloads.
Definition:
udp-client.h:43
ns3::UdpClientHelper::m_factory
ObjectFactory m_factory
Definition:
udp-client-server-helper.h:124
ns3::UdpTraceClient
A trace based streamer.
Definition:
udp-trace-client.cc:43
ns3::UdpServer::GetTypeId
static TypeId GetTypeId(void)
Definition:
udp-server.cc:44
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:46
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::AddressValue
hold objects of type ns3::Address
udp-client-server-helper.h
ns3::UdpServerHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition:
udp-client-server-helper.cc:46
ns3::UdpServerHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Definition:
udp-client-server-helper.cc:40
first.address
tuple address
Definition:
first.py:37
ns3::UdpServer
A Udp server. Receives UDP packets from a remote host. UDP packets carry a 32bits sequence number fol...
Definition:
udp-server.h:45
src
applications
helper
udp-client-server-helper.cc
Generated on Sat Nov 16 2013 16:17:35 for ns-3 by
1.8.5