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 * Create UdpEchoServerHelper which will make life easier for people trying
37 * to set up simulations with echos.
38 *
39 * @param address The address the server will bind to
40 */
41 UdpEchoServerHelper(const Address& address);
42};
43
44/**
45 * @ingroup udpecho
46 * @brief Create an application which sends a UDP packet and waits for an echo of this packet
47 */
49{
50 public:
51 /**
52 * Create UdpEchoClientHelper which will make life easier for people trying
53 * to set up simulations with echos. Use this variant with addresses that do
54 * not include a port value (e.g., Ipv4Address and Ipv6Address).
55 *
56 * @param ip The IP address of the remote udp echo server
57 * @param port The port number of the remote udp echo server
58 */
59 UdpEchoClientHelper(const Address& ip, uint16_t port);
60
61 /**
62 * Create UdpEchoClientHelper which will make life easier for people trying
63 * to set up simulations with echos. Use this variant with addresses that do
64 * include a port value (e.g., InetSocketAddress and Inet6SocketAddress).
65 *
66 * @param addr The address of the remote udp echo server
67 */
68 UdpEchoClientHelper(const Address& addr);
69
70 /**
71 * Given a pointer to a UdpEchoClient application, set the data fill of the
72 * packet (what is sent as data to the server) to the contents of the fill
73 * string (including the trailing zero terminator).
74 *
75 * @warning The size of resulting echo packets will be automatically adjusted
76 * to reflect the size of the fill string -- this means that the PacketSize
77 * attribute may be changed as a result of this call.
78 *
79 * @param app Smart pointer to the application (real type must be UdpEchoClient).
80 * @param fill The string to use as the actual echo data bytes.
81 */
82 void SetFill(Ptr<Application> app, const std::string& fill);
83
84 /**
85 * Given a pointer to a UdpEchoClient application, set the data fill of the
86 * packet (what is sent as data to the server) to the contents of the fill
87 * byte.
88 *
89 * The fill byte will be used to initialize the contents of the data packet.
90 *
91 * @warning The size of resulting echo packets will be automatically adjusted
92 * to reflect the dataLength parameter -- this means that the PacketSize
93 * attribute may be changed as a result of this call.
94 *
95 * @param app Smart pointer to the application (real type must be UdpEchoClient).
96 * @param fill The byte to be repeated in constructing the packet data..
97 * @param dataLength The desired length of the resulting echo packet data.
98 */
99 void SetFill(Ptr<Application> app, uint8_t fill, uint32_t dataLength);
100
101 /**
102 * Given a pointer to a UdpEchoClient application, set the data fill of the
103 * packet (what is sent as data to the server) to the contents of the fill
104 * buffer, repeated as many times as is required.
105 *
106 * Initializing the fill to the contents of a single buffer is accomplished
107 * by providing a complete buffer with fillLength set to your desired
108 * dataLength
109 *
110 * @warning The size of resulting echo packets will be automatically adjusted
111 * to reflect the dataLength parameter -- this means that the PacketSize
112 * attribute of the Application may be changed as a result of this call.
113 *
114 * @param app Smart pointer to the application (real type must be UdpEchoClient).
115 * @param fill The fill pattern to use when constructing packets.
116 * @param fillLength The number of bytes in the provided fill pattern.
117 * @param dataLength The desired length of the final echo data.
118 */
119 void SetFill(Ptr<Application> app, uint8_t* fill, uint32_t fillLength, uint32_t dataLength);
120};
121
122} // namespace ns3
123
124#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.