~ubuntu-branches/ubuntu/quantal/ns3/quantal

« back to all changes in this revision

Viewing changes to ns-3.12.1/src/applications/helper/udp-echo-helper.h

  • Committer: Package Import Robot
  • Author(s): YunQiang Su, Aron Xu, YunQiang Su, Upstream
  • Date: 2012-01-06 00:35:42 UTC
  • mfrom: (10.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120106003542-vcn5g03mhapm991h
Tags: 3.13+dfsg-1
[ Aron Xu ]:
        add tag binary and binary-indep, 
  for not build doc when --binary-arch (Closes: #654493).
[ YunQiang Su ]
        add waf 1.5/1.6 source to debian directory, 
  and build waf from there (Closes: #642217).
[ Upstream ]
  Successfully link with --as-needed option (Closes: #642225).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#ifndef UDP_ECHO_HELPER_H
21
 
#define UDP_ECHO_HELPER_H
22
 
 
23
 
#include <stdint.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"
28
 
 
29
 
namespace ns3 {
30
 
 
31
 
/**
32
 
 * \brief Create a server application which waits for input udp packets
33
 
 *        and sends them back to the original sender.
34
 
 */
35
 
class UdpEchoServerHelper
36
 
{
37
 
public:
38
 
  /**
39
 
   * Create UdpEchoServerHelper which will make life easier for people trying
40
 
   * to set up simulations with echos.
41
 
   *
42
 
   * \param port The port the server will wait on for incoming packets
43
 
   */
44
 
  UdpEchoServerHelper (uint16_t port);
45
 
 
46
 
  /**
47
 
   * Record an attribute to be set in each Application after it is is created.
48
 
   *
49
 
   * \param name the name of the attribute to set
50
 
   * \param value the value of the attribute to set
51
 
   */
52
 
  void SetAttribute (std::string name, const AttributeValue &value);
53
 
 
54
 
  /**
55
 
   * Create a UdpEchoServerApplication on the specified Node.
56
 
   *
57
 
   * \param node The node on which to create the Application.  The node is
58
 
   *             specified by a Ptr<Node>.
59
 
   *
60
 
   * \returns An ApplicationContainer holding the Application created,
61
 
   */
62
 
  ApplicationContainer Install (Ptr<Node> node) const;
63
 
 
64
 
  /**
65
 
   * Create a UdpEchoServerApplication on specified node
66
 
   *
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.
70
 
   *
71
 
   * \returns An ApplicationContainer holding the Application created.
72
 
   */
73
 
  ApplicationContainer Install (std::string nodeName) const;
74
 
 
75
 
  /**
76
 
   * \param c The nodes on which to create the Applications.  The nodes
77
 
   *          are specified by a NodeContainer.
78
 
   *
79
 
   * Create one udp echo server application on each of the Nodes in the
80
 
   * NodeContainer.
81
 
   *
82
 
   * \returns The applications created, one Application per Node in the 
83
 
   *          NodeContainer.
84
 
   */
85
 
  ApplicationContainer Install (NodeContainer c) const;
86
 
 
87
 
private:
88
 
  /**
89
 
   * \internal
90
 
   */
91
 
  Ptr<Application> InstallPriv (Ptr<Node> node) const;
92
 
 
93
 
  ObjectFactory m_factory;
94
 
};
95
 
 
96
 
/**
97
 
 * \brief create an application which sends a udp packet and waits for an echo of this packet
98
 
 */
99
 
class UdpEchoClientHelper
100
 
{
101
 
public:
102
 
  /**
103
 
   * Create UdpEchoClientHelper which will make life easier for people trying
104
 
   * to set up simulations with echos.
105
 
   *
106
 
   * \param ip The IP address of the remote udp echo server
107
 
   * \param port The port number of the remote udp echo server
108
 
   */
109
 
  UdpEchoClientHelper (Ipv4Address ip, uint16_t port);
110
 
 
111
 
  /**
112
 
   * Record an attribute to be set in each Application after it is is created.
113
 
   *
114
 
   * \param name the name of the attribute to set
115
 
   * \param value the value of the attribute to set
116
 
   */
117
 
  void SetAttribute (std::string name, const AttributeValue &value);
118
 
 
119
 
  /**
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).
123
 
   *
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.
127
 
   *
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.
130
 
   */
131
 
  void SetFill (Ptr<Application> app, std::string fill);
132
 
 
133
 
  /**
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
136
 
   * byte.
137
 
   *
138
 
   * The fill byte will be used to initialize the contents of the data packet.
139
 
   * 
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.
143
 
   *
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.
147
 
   */
148
 
  void SetFill (Ptr<Application> app, uint8_t fill, uint32_t dataLength);
149
 
 
150
 
  /**
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.
154
 
   *
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 
157
 
   * dataLength
158
 
   *
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.
162
 
   *
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.
167
 
   */
168
 
  void SetFill (Ptr<Application> app, uint8_t *fill, uint32_t fillLength, uint32_t dataLength);
169
 
 
170
 
  /**
171
 
   * Create a udp echo client application on the specified node.  The Node
172
 
   * is provided as a Ptr<Node>.
173
 
   *
174
 
   * \param node The Ptr<Node> on which to create the UdpEchoClientApplication.
175
 
   *
176
 
   * \returns An ApplicationContainer that holds a Ptr<Application> to the 
177
 
   *          application created
178
 
   */
179
 
  ApplicationContainer Install (Ptr<Node> node) const;
180
 
 
181
 
  /**
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.
185
 
   *
186
 
   * \param nodeName The name of the node on which to create the UdpEchoClientApplication
187
 
   *
188
 
   * \returns An ApplicationContainer that holds a Ptr<Application> to the 
189
 
   *          application created
190
 
   */
191
 
  ApplicationContainer Install (std::string nodeName) const;
192
 
 
193
 
  /**
194
 
   * \param c the nodes
195
 
   *
196
 
   * Create one udp echo client application on each of the input nodes
197
 
   *
198
 
   * \returns the applications created, one application per input node.
199
 
   */
200
 
  ApplicationContainer Install (NodeContainer c) const;
201
 
 
202
 
private:
203
 
  Ptr<Application> InstallPriv (Ptr<Node> node) const;
204
 
  ObjectFactory m_factory;
205
 
};
206
 
 
207
 
} // namespace ns3
208
 
 
209
 
#endif /* UDP_ECHO_HELPER_H */