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
src
applications
helper
udp-echo-helper.cc
Generated on Tue May 14 2013 11:08:16 for ns-3 by
1.8.1.2