1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright (c) 2008 INRIA
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;
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.
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
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
#ifndef UDP_ECHO_HELPER_H
21
#define UDP_ECHO_HELPER_H
24
#include "ns3/application-container.h"
25
#include "ns3/node-container.h"
26
#include "ns3/object-factory.h"
27
#include "ns3/ipv4-address.h"
32
* \brief Create a server application which waits for input udp packets
33
* and sends them back to the original sender.
35
class UdpEchoServerHelper
39
* Create UdpEchoServerHelper which will make life easier for people trying
40
* to set up simulations with echos.
42
* \param port The port the server will wait on for incoming packets
44
UdpEchoServerHelper (uint16_t port);
47
* Record an attribute to be set in each Application after it is is created.
49
* \param name the name of the attribute to set
50
* \param value the value of the attribute to set
52
void SetAttribute (std::string name, const AttributeValue &value);
55
* Create a UdpEchoServerApplication on the specified Node.
57
* \param node The node on which to create the Application. The node is
58
* specified by a Ptr<Node>.
60
* \returns An ApplicationContainer holding the Application created,
62
ApplicationContainer Install (Ptr<Node> node) const;
65
* Create a UdpEchoServerApplication on specified node
67
* \param nodeName The node on which to create the application. The node
68
* is specified by a node name previously registered with
69
* the Object Name Service.
71
* \returns An ApplicationContainer holding the Application created.
73
ApplicationContainer Install (std::string nodeName) const;
76
* \param c The nodes on which to create the Applications. The nodes
77
* are specified by a NodeContainer.
79
* Create one udp echo server application on each of the Nodes in the
82
* \returns The applications created, one Application per Node in the
85
ApplicationContainer Install (NodeContainer c) const;
91
Ptr<Application> InstallPriv (Ptr<Node> node) const;
93
ObjectFactory m_factory;
97
* \brief create an application which sends a udp packet and waits for an echo of this packet
99
class UdpEchoClientHelper
103
* Create UdpEchoClientHelper which will make life easier for people trying
104
* to set up simulations with echos.
106
* \param ip The IP address of the remote udp echo server
107
* \param port The port number of the remote udp echo server
109
UdpEchoClientHelper (Ipv4Address ip, uint16_t port);
112
* Record an attribute to be set in each Application after it is is created.
114
* \param name the name of the attribute to set
115
* \param value the value of the attribute to set
117
void SetAttribute (std::string name, const AttributeValue &value);
120
* Given a pointer to a UdpEchoClient application, set the data fill of the
121
* packet (what is sent as data to the server) to the contents of the fill
122
* string (including the trailing zero terminator).
124
* \warning The size of resulting echo packets will be automatically adjusted
125
* to reflect the size of the fill string -- this means that the PacketSize
126
* attribute may be changed as a result of this call.
128
* \param app Smart pointer to the application (real type must be UdpEchoClient).
129
* \param fill The string to use as the actual echo data bytes.
131
void SetFill (Ptr<Application> app, std::string fill);
134
* Given a pointer to a UdpEchoClient application, set the data fill of the
135
* packet (what is sent as data to the server) to the contents of the fill
138
* The fill byte will be used to initialize the contents of the data packet.
140
* \warning The size of resulting echo packets will be automatically adjusted
141
* to reflect the dataLength parameter -- this means that the PacketSize
142
* attribute may be changed as a result of this call.
144
* \param app Smart pointer to the application (real type must be UdpEchoClient).
145
* \param fill The byte to be repeated in constructing the packet data..
146
* \param dataLength The desired length of the resulting echo packet data.
148
void SetFill (Ptr<Application> app, uint8_t fill, uint32_t dataLength);
151
* Given a pointer to a UdpEchoClient application, set the data fill of the
152
* packet (what is sent as data to the server) to the contents of the fill
153
* buffer, repeated as many times as is required.
155
* Initializing the fill to the contents of a single buffer is accomplished
156
* by providing a complete buffer with fillLength set to your desired
159
* \warning The size of resulting echo packets will be automatically adjusted
160
* to reflect the dataLength parameter -- this means that the PacketSize
161
* attribute of the Application may be changed as a result of this call.
163
* \param app Smart pointer to the application (real type must be UdpEchoClient).
164
* \param fill The fill pattern to use when constructing packets.
165
* \param fillLength The number of bytes in the provided fill pattern.
166
* \param dataLength The desired length of the final echo data.
168
void SetFill (Ptr<Application> app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength);
171
* Create a udp echo client application on the specified node. The Node
172
* is provided as a Ptr<Node>.
174
* \param node The Ptr<Node> on which to create the UdpEchoClientApplication.
176
* \returns An ApplicationContainer that holds a Ptr<Application> to the
177
* application created
179
ApplicationContainer Install (Ptr<Node> node) const;
182
* Create a udp echo client application on the specified node. The Node
183
* is provided as a string name of a Node that has been previously
184
* associated using the Object Name Service.
186
* \param nodeName The name of the node on which to create the UdpEchoClientApplication
188
* \returns An ApplicationContainer that holds a Ptr<Application> to the
189
* application created
191
ApplicationContainer Install (std::string nodeName) const;
196
* Create one udp echo client application on each of the input nodes
198
* \returns the applications created, one application per input node.
200
ApplicationContainer Install (NodeContainer c) const;
203
Ptr<Application> InstallPriv (Ptr<Node> node) const;
204
ObjectFactory m_factory;
209
#endif /* UDP_ECHO_HELPER_H */