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-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
28
UdpEchoServerHelper::UdpEchoServerHelper
(uint16_t
port
)
29
{
30
m_factory
.
SetTypeId
(
UdpEchoServer::GetTypeId
());
31
SetAttribute
(
"Port"
,
UintegerValue
(port));
32
}
33
34
void
35
UdpEchoServerHelper::SetAttribute
(
36
std::string name,
37
const
AttributeValue
&value)
38
{
39
m_factory
.
Set
(name, value);
40
}
41
42
ApplicationContainer
43
UdpEchoServerHelper::Install
(
Ptr<Node>
node)
const
44
{
45
return
ApplicationContainer
(
InstallPriv
(node));
46
}
47
48
ApplicationContainer
49
UdpEchoServerHelper::Install
(std::string nodeName)
const
50
{
51
Ptr<Node>
node = Names::Find<Node> (nodeName);
52
return
ApplicationContainer
(
InstallPriv
(node));
53
}
54
55
ApplicationContainer
56
UdpEchoServerHelper::Install
(
NodeContainer
c)
const
57
{
58
ApplicationContainer
apps;
59
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
60
{
61
apps.
Add
(
InstallPriv
(*i));
62
}
63
64
return
apps;
65
}
66
67
Ptr<Application>
68
UdpEchoServerHelper::InstallPriv
(
Ptr<Node>
node)
const
69
{
70
Ptr<Application>
app =
m_factory
.
Create
<
UdpEchoServer
> ();
71
node->
AddApplication
(app);
72
73
return
app;
74
}
75
76
UdpEchoClientHelper::UdpEchoClientHelper
(
Address
address
, uint16_t
port
)
77
{
78
m_factory
.
SetTypeId
(
UdpEchoClient::GetTypeId
());
79
SetAttribute
(
"RemoteAddress"
,
AddressValue
(address));
80
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
81
}
82
83
UdpEchoClientHelper::UdpEchoClientHelper
(
Ipv4Address
address
, uint16_t
port
)
84
{
85
m_factory
.
SetTypeId
(
UdpEchoClient::GetTypeId
());
86
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
87
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
88
}
89
90
UdpEchoClientHelper::UdpEchoClientHelper
(
Ipv6Address
address
, uint16_t
port
)
91
{
92
m_factory
.
SetTypeId
(
UdpEchoClient::GetTypeId
());
93
SetAttribute
(
"RemoteAddress"
,
AddressValue
(
Address
(address)));
94
SetAttribute
(
"RemotePort"
,
UintegerValue
(port));
95
}
96
97
void
98
UdpEchoClientHelper::SetAttribute
(
99
std::string name,
100
const
AttributeValue
&value)
101
{
102
m_factory
.
Set
(name, value);
103
}
104
105
void
106
UdpEchoClientHelper::SetFill
(
Ptr<Application>
app, std::string fill)
107
{
108
app->GetObject<
UdpEchoClient
>()->
SetFill
(fill);
109
}
110
111
void
112
UdpEchoClientHelper::SetFill
(
Ptr<Application>
app, uint8_t fill, uint32_t dataLength)
113
{
114
app->GetObject<
UdpEchoClient
>()->
SetFill
(fill, dataLength);
115
}
116
117
void
118
UdpEchoClientHelper::SetFill
(
Ptr<Application>
app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength)
119
{
120
app->GetObject<
UdpEchoClient
>()->
SetFill
(fill, fillLength, dataLength);
121
}
122
123
ApplicationContainer
124
UdpEchoClientHelper::Install
(
Ptr<Node>
node)
const
125
{
126
return
ApplicationContainer
(
InstallPriv
(node));
127
}
128
129
ApplicationContainer
130
UdpEchoClientHelper::Install
(std::string nodeName)
const
131
{
132
Ptr<Node>
node = Names::Find<Node> (nodeName);
133
return
ApplicationContainer
(
InstallPriv
(node));
134
}
135
136
ApplicationContainer
137
UdpEchoClientHelper::Install
(
NodeContainer
c)
const
138
{
139
ApplicationContainer
apps;
140
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
141
{
142
apps.
Add
(
InstallPriv
(*i));
143
}
144
145
return
apps;
146
}
147
148
Ptr<Application>
149
UdpEchoClientHelper::InstallPriv
(
Ptr<Node>
node)
const
150
{
151
Ptr<Application>
app =
m_factory
.
Create
<
UdpEchoClient
> ();
152
node->
AddApplication
(app);
153
154
return
app;
155
}
156
157
}
// 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::Ptr< Node >
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Definition:
node-container.h:41
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
udp-echo-helper.h
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:40
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:77
port
uint16_t port
Definition:
dsdv-manet.cc:44
ns3::Address
a polymophic address class
Definition:
address.h:86
ns3::UdpEchoServerHelper::Install
ApplicationContainer Install(Ptr< Node > node) const
Definition:
udp-echo-helper.cc:43
ns3::UdpEchoServerHelper::InstallPriv
Ptr< Application > InstallPriv(Ptr< Node > node) const
Definition:
udp-echo-helper.cc:68
ns3::UdpEchoClientHelper::UdpEchoClientHelper
UdpEchoClientHelper(Address ip, uint16_t port)
Definition:
udp-echo-helper.cc:76
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::UdpEchoClient
A Udp Echo client.
Definition:
udp-echo-client.h:39
ns3::UdpEchoClientHelper::SetFill
void SetFill(Ptr< Application > app, std::string fill)
Definition:
udp-echo-helper.cc:106
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::UdpEchoClientHelper::InstallPriv
Ptr< Application > InstallPriv(Ptr< Node > node) const
Definition:
udp-echo-helper.cc:149
ns3::UdpEchoClient::GetTypeId
static TypeId GetTypeId(void)
Definition:
udp-echo-client.cc:38
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:58
ns3::UdpEchoServerHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Definition:
udp-echo-helper.cc:35
ns3::UdpEchoServerHelper::m_factory
ObjectFactory m_factory
Definition:
udp-echo-helper.h:94
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
ns3::UdpEchoServerHelper::UdpEchoServerHelper
UdpEchoServerHelper(uint16_t port)
Definition:
udp-echo-helper.cc:28
ns3::UdpEchoServer
A Udp Echo server.
Definition:
udp-echo-server.h:43
ns3::UdpEchoClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Definition:
udp-echo-helper.cc:98
first.address
tuple address
Definition:
first.py:37
ns3::UdpEchoServer::GetTypeId
static TypeId GetTypeId(void)
Definition:
udp-echo-server.cc:41
ns3::UdpEchoClientHelper::Install
ApplicationContainer Install(Ptr< Node > node) const
Definition:
udp-echo-helper.cc:124
ns3::UdpEchoClientHelper::m_factory
ObjectFactory m_factory
Definition:
udp-echo-helper.h:207
src
applications
helper
udp-echo-helper.cc
Generated on Sat Nov 16 2013 12:55:22 for ns-3 by
1.8.5