A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flent-application.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Georgia Institute of Technology
3 * Copyright (c) 2020 Harsha Sharma : Flent application
4 * Copyright (c) 2021 NITK Surathkal
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 * Author: Harsha Sharma <harshasha256@gmail.com>
9 * (adapted from bulk-send-application.h and
10 * packet-sink-application.h written by George F. Riley)
11 *
12 * Modified by: Ameya Deshpande <ameyanrd@outlook.com>
13 * Bhaskar Kataria <bhaskar.k7920@gmail.com> (Post processing of raw data)
14 */
15
16#ifndef FLENT_APPLICATION_H
17#define FLENT_APPLICATION_H
18
20#include "packet-sink.h"
21#include "udp-echo-client.h"
22#include "udp-echo-server.h"
23
24#include "ns3/address.h"
25#include "ns3/application.h"
26#include "ns3/event-id.h"
27#include "ns3/node-list.h"
28#include "ns3/ping.h"
29#include "ns3/ptr.h"
30
31#include <memory>
32#include <string>
33
34namespace ns3
35{
36
37class SeqTsEchoHeader;
38
39/**
40 * @ingroup applications
41 * @defgroup flent FlentApplication
42 *
43 * This application provides a basic model of the Flent traffic generator. In practice,
44 * Flent is a wrapper around three traffic generation tools: netperf (for TCP),
45 * iperf (for UDP) and ping (for ICMP). Flent also provides output in a JSON-formatted
46 * data file, and plotting support via matplotlib.
47 */
48
49/**
50 * @ingroup flent
51 *
52 * @brief Flent is a network benchmarking tool
53 *
54 * This application provides a basic model of the Flent traffic generator. In practice,
55 * Flent is a wrapper around three traffic generation tools: netperf (for TCP),
56 * iperf (for UDP) and ping (for ICMP). Flent also provides output in a JSON-formatted
57 * data file, and plotting support via matplotlib.
58 *
59 * @warning Note:
60 * Unlike standard ns-3 applications, FlentApplication automatically configures peer
61 * applications on the target host node during initialization.
62 *
63 * Because FlentApplication binds these peer applications to specific,
64 * predefined socket ports (e.g., port 9020 for TCP uploads), you cannot target
65 * the same host node with multiple Flent applications at the same time. Doing so
66 * will cause the newly installed sinks to clash over the same ports, resulting in
67 * socket binding conflicts and simulation failures.
68 */
70{
71 public:
72 /**
73 * @brief Get the type ID.
74 * @return the object TypeId
75 */
76 static TypeId GetTypeId();
77
79
81
82 protected:
83 /**
84 * In this method, the following tasks are performed:
85 * 1) set the host node, which is derived from the host address.
86 * 2) put the local bind address as the first address of the first non-loopback interface
87 * (if not set by the user explicitly), and
88 * 3) override the application stop time from the Length attribute set by the user.
89 *
90 * @sa Application::DoInitialize
91 */
92 void DoInitialize() override;
93
94 /**
95 * @sa Application::DoDispose
96 */
97 void DoDispose() override;
98
99 private:
100 // inherited from Application base class.
101 void StartApplication() override;
102 void StopApplication() override;
103
104 /**
105 * @brief Add Flent metadata to the output document.
106 */
107 void AddMetadata();
108
109 /**
110 * @brief sink for packet transmissions.
111 * @param idx Index of the flow
112 * @param packet Pointer to packet sent
113 */
114 void TraceSentPacket(std::size_t idx, Ptr<const Packet> packet);
115
116 /**
117 * @brief sink for packet received.
118 * @param idx Index of the flow
119 * @param packet Pointer to packet received
120 * @param address Address of the sender
121 */
122 void TraceReceivedPacket(std::size_t idx, Ptr<const Packet> packet, const Address& address);
123
124 /**
125 * @brief Iterates through the node list and finds the node
126 * pointer for the given hostAddress
127 * @param [in] hostAddress host node IP
128 * @return The node with the specified IP.
129 *
130 */
131 Ptr<Node> GetHostNode(Ipv4Address hostAddress) const;
132
133 /**
134 * @brief Ping RTT Trace function
135 * @param seq Echo sequence number
136 * @param rtt Round Trip Time delta from the sent time
137 */
138 void TraceReceivedPing(uint16_t seq, Time rtt);
139
140 /**
141 * @brief UDP Ping RTT Trace function
142 * @param idx Index of the QoS flow (0=BE, 1=BK, 2=EF)
143 * @param packet UDP Ping Packet
144 * @param address Address of the destination
145 * @param localAddress Local address of the sender
146 * @param header SeqTsEchoHeader header
147 */
148 void TraceReceivedUdpPing(std::size_t idx,
149 Ptr<const Packet> packet,
150 const Address& address,
151 const Address& localAddress,
152 const SeqTsEchoHeader& header);
153
154 /**
155 * @brief Calculate the Time in UTC time format
156 * from the number of seconds.
157 * @return The time in UTC format
158 */
159 std::string GetUtcFormatTime() const;
160
161 /**
162 * @brief Goodput calculation for the i-th flow
163 * based on the bytes sent.
164 *
165 * Index i can have various values from 0 to 3 for
166 * the four upload flows in case of RRUL test.
167 *
168 * @param [in] name Name of the flow
169 * @param [in] i index of the flow
170 */
171 void GoodputSamplingUpload(std::string name, int i);
172
173 /**
174 * @brief Goodput calculation for the i-th flow
175 * based on the bytes received.
176 *
177 * Index i can have various values from 0 to 3 for
178 * the four download flows in case of RRUL test.
179 *
180 * @param [in] name Name of the flow
181 * @param [in] i index of the flow
182 */
183 void GoodputSamplingDownload(std::string name, int i);
184
185 /**
186 * @brief Fill x_values parameter in Flent file.
187 * Adds x parameter values with the difference of stepSize
188 */
189 void FillXValues();
190
191 /**
192 * @brief Process raw values and add the processed result in the Flent file.
193 */
194 void ProcessRawValues();
195
196 double m_currTime; //!< Derived epoch anchor in seconds
197 struct Output; //!< Opaque JSON output document (defined in the .cc file)
198 std::unique_ptr<Output> m_output; //!< Json output
199 Time m_length; //!< Test duration
200 std::string m_outputFilename; ///< Output file path (see OutputFilename attribute)
201 std::string m_testName; //!< Flent test name
202 Time m_t0; ///< Epoch anchor for output timestamps (see T0 attribute)
203 bool m_useWallClockT0; ///< Use the wall clock instead of m_t0 (see UseWallClockT0 attribute)
204 Address m_hostAddress; //!< Host address
205 Address m_localBindAddress; //!< Local bind address
206 std::string m_imageText; //!< Text to be included in plot
207 Time m_stepSize; //!< Measurement data point step size
208 std::array<uint32_t, 4> m_bytesSent{}; //!< sent data counters
209 std::array<uint32_t, 4> m_bytesReceived{}; //!< receive data counters
210
211 /* Applications */
212 Ptr<Ping> m_ping; //!< Ping Application for latency measurement (ping, rrul tests)
213
214 // The RRUL (Realtime Response Under Load) test specification (rrul.conf from real Flent)
215 // defines 4 concurrent TCP streams in each direction, assigned to different QoS markings (BE,
216 // BK, CS5, EF). This helps test how different traffic classes are handled when the link is
217 // under heavy load
218 std::array<Ptr<PacketSink>, 4>
219 m_packetSinkUp; //!< PacketSink Applications for Upload flows (tcp_upload, rrul tests)
220 std::array<Ptr<PacketSink>, 4>
221 m_packetSinkDown; //!< PacketSink Applications for Download flows (tcp_download, rrul tests)
222 std::array<Ptr<BulkSendApplication>, 4>
223 m_bulkSendUp; //!< BulkSend Applications for Upload flows (tcp_upload, rrul tests)
224 std::array<Ptr<BulkSendApplication>, 4>
225 m_bulkSendDown; //!< BulkSend Applications for Download flows (tcp_download, rrul tests)
226
227 // The RRUL specification defines 3 UDP ping streams marked with different QoS
228 // markings (EF, BK, and BE) to measure latency and jitter for different
229 // traffic classes under heavy load.
230 std::array<Ptr<UdpEchoServer>, 3> m_udpServer; //!< UdpEchoServer Applications
231 std::array<Ptr<UdpEchoClient>, 3> m_udpClient; //!< UdpEchoClient Applications
232};
233
234} // namespace ns3
235
236#endif /* FLENT_APPLICATION_H */
a polymophic address class
Definition address.h:114
std::string GetUtcFormatTime() const
Calculate the Time in UTC time format from the number of seconds.
double m_currTime
Derived epoch anchor in seconds.
~FlentApplication() override
std::array< Ptr< BulkSendApplication >, 4 > m_bulkSendUp
BulkSend Applications for Upload flows (tcp_upload, rrul tests).
void StopApplication() override
Application specific shutdown code.
std::array< uint32_t, 4 > m_bytesReceived
receive data counters
std::string m_imageText
Text to be included in plot.
std::array< Ptr< UdpEchoClient >, 3 > m_udpClient
UdpEchoClient Applications.
Time m_t0
Epoch anchor for output timestamps (see T0 attribute).
std::array< uint32_t, 4 > m_bytesSent
sent data counters
void FillXValues()
Fill x_values parameter in Flent file.
void ProcessRawValues()
Process raw values and add the processed result in the Flent file.
void TraceReceivedUdpPing(std::size_t idx, Ptr< const Packet > packet, const Address &address, const Address &localAddress, const SeqTsEchoHeader &header)
UDP Ping RTT Trace function.
std::array< Ptr< UdpEchoServer >, 3 > m_udpServer
UdpEchoServer Applications.
void TraceSentPacket(std::size_t idx, Ptr< const Packet > packet)
sink for packet transmissions.
bool m_useWallClockT0
Use the wall clock instead of m_t0 (see UseWallClockT0 attribute).
static TypeId GetTypeId()
Get the type ID.
std::unique_ptr< Output > m_output
Opaque JSON output document (defined in the .cc file).
std::array< Ptr< PacketSink >, 4 > m_packetSinkUp
PacketSink Applications for Upload flows (tcp_upload, rrul tests).
Time m_length
Test duration.
Time m_stepSize
Measurement data point step size.
void GoodputSamplingUpload(std::string name, int i)
Goodput calculation for the i-th flow based on the bytes sent.
std::string m_testName
Flent test name.
Address m_hostAddress
Host address.
Address m_localBindAddress
Local bind address.
void TraceReceivedPing(uint16_t seq, Time rtt)
Ping RTT Trace function.
std::array< Ptr< PacketSink >, 4 > m_packetSinkDown
PacketSink Applications for Download flows (tcp_download, rrul tests).
std::string m_outputFilename
Output file path (see OutputFilename attribute).
void DoInitialize() override
In this method, the following tasks are performed: 1) set the host node, which is derived from the ho...
Ptr< Ping > m_ping
Ping Application for latency measurement (ping, rrul tests).
void AddMetadata()
Add Flent metadata to the output document.
Ptr< Node > GetHostNode(Ipv4Address hostAddress) const
Iterates through the node list and finds the node pointer for the given hostAddress.
void TraceReceivedPacket(std::size_t idx, Ptr< const Packet > packet, const Address &address)
sink for packet received.
void StartApplication() override
Application specific startup code.
void GoodputSamplingDownload(std::string name, int i)
Goodput calculation for the i-th flow based on the bytes received.
std::array< Ptr< BulkSendApplication >, 4 > m_bulkSendDown
BulkSend Applications for Download flows (tcp_download, rrul tests).
Ipv4 addresses are stored in host order in this class.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Packet header to carry sequence number and two timestamps.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Flent output document, in JSON format.