A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
udp-echo-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef UDP_ECHO_HELPER_H
10#define UDP_ECHO_HELPER_H
11
12#include <ns3/application-helper.h>
13
14#include <stdint.h>
15
16namespace ns3
17{
18
19/**
20 * \ingroup udpecho
21 * \brief Create a server application which waits for input UDP packets
22 * and sends them back to the original sender.
23 */
25{
26 public:
27 /**
28 * Create UdpEchoServerHelper which will make life easier for people trying
29 * to set up simulations with echos.
30 *
31 * \param port The port the server will wait on for incoming packets
32 */
33 UdpEchoServerHelper(uint16_t port);
34};
35
36/**
37 * \ingroup udpecho
38 * \brief Create an application which sends a UDP packet and waits for an echo of this packet
39 */
41{
42 public:
43 /**
44 * Create UdpEchoClientHelper which will make life easier for people trying
45 * to set up simulations with echos. Use this variant with addresses that do
46 * not include a port value (e.g., Ipv4Address and Ipv6Address).
47 *
48 * \param ip The IP address of the remote udp echo server
49 * \param port The port number of the remote udp echo server
50 */
51 UdpEchoClientHelper(const Address& ip, uint16_t port);
52 /**
53 * Create UdpEchoClientHelper which will make life easier for people trying
54 * to set up simulations with echos. Use this variant with addresses that do
55 * include a port value (e.g., InetSocketAddress and Inet6SocketAddress).
56 *
57 * \param addr The address of the remote udp echo server
58 */
59 UdpEchoClientHelper(const Address& addr);
60
61 /**
62 * Given a pointer to a UdpEchoClient application, set the data fill of the
63 * packet (what is sent as data to the server) to the contents of the fill
64 * string (including the trailing zero terminator).
65 *
66 * \warning The size of resulting echo packets will be automatically adjusted
67 * to reflect the size of the fill string -- this means that the PacketSize
68 * attribute may be changed as a result of this call.
69 *
70 * \param app Smart pointer to the application (real type must be UdpEchoClient).
71 * \param fill The string to use as the actual echo data bytes.
72 */
73 void SetFill(Ptr<Application> app, const std::string& fill);
74
75 /**
76 * Given a pointer to a UdpEchoClient application, set the data fill of the
77 * packet (what is sent as data to the server) to the contents of the fill
78 * byte.
79 *
80 * The fill byte will be used to initialize the contents of the data packet.
81 *
82 * \warning The size of resulting echo packets will be automatically adjusted
83 * to reflect the dataLength parameter -- this means that the PacketSize
84 * attribute may be changed as a result of this call.
85 *
86 * \param app Smart pointer to the application (real type must be UdpEchoClient).
87 * \param fill The byte to be repeated in constructing the packet data..
88 * \param dataLength The desired length of the resulting echo packet data.
89 */
90 void SetFill(Ptr<Application> app, uint8_t fill, uint32_t dataLength);
91
92 /**
93 * Given a pointer to a UdpEchoClient application, set the data fill of the
94 * packet (what is sent as data to the server) to the contents of the fill
95 * buffer, repeated as many times as is required.
96 *
97 * Initializing the fill to the contents of a single buffer is accomplished
98 * by providing a complete buffer with fillLength set to your desired
99 * dataLength
100 *
101 * \warning The size of resulting echo packets will be automatically adjusted
102 * to reflect the dataLength parameter -- this means that the PacketSize
103 * attribute of the Application may be changed as a result of this call.
104 *
105 * \param app Smart pointer to the application (real type must be UdpEchoClient).
106 * \param fill The fill pattern to use when constructing packets.
107 * \param fillLength The number of bytes in the provided fill pattern.
108 * \param dataLength The desired length of the final echo data.
109 */
110 void SetFill(Ptr<Application> app, uint8_t* fill, uint32_t fillLength, uint32_t dataLength);
111};
112
113} // namespace ns3
114
115#endif /* UDP_ECHO_HELPER_H */
a polymophic address class
Definition address.h:90
A helper to make it easier to instantiate an application on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
Create an application which sends a UDP packet and waits for an echo of this packet.
UdpEchoClientHelper(const Address &ip, uint16_t port)
Create UdpEchoClientHelper which will make life easier for people trying to set up simulations with e...
void SetFill(Ptr< Application > app, const std::string &fill)
Given a pointer to a UdpEchoClient application, set the data fill of the packet (what is sent as data...
Create a server application which waits for input UDP packets and sends them back to the original sen...
UdpEchoServerHelper(uint16_t port)
Create UdpEchoServerHelper which will make life easier for people trying to set up simulations with e...
uint16_t port
Definition dsdv-manet.cc:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.