A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bulk-send-application.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Georgia Institute of Technology
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: George F. Riley <riley@ece.gatech.edu>
7 */
8
9#ifndef BULK_SEND_APPLICATION_H
10#define BULK_SEND_APPLICATION_H
11
12#include "seq-ts-size-header.h"
13#include "source-application.h"
14
15#include "ns3/event-id.h"
16#include "ns3/ptr.h"
17#include "ns3/traced-callback.h"
18
19namespace ns3
20{
21
22class TcpHeader;
23class TcpSocketBase;
24
25/**
26 * @ingroup applications
27 * @defgroup bulksend BulkSendApplication
28 *
29 * This traffic generator simply sends data
30 * as fast as possible up to MaxBytes or until
31 * the application is stopped (if MaxBytes is
32 * zero). Once the lower layer send buffer is
33 * filled, it waits until space is free to
34 * send more data, essentially keeping a
35 * constant flow of data. Only SOCK_STREAM
36 * and SOCK_SEQPACKET sockets are supported.
37 * For example, TCP sockets can be used, but
38 * UDP sockets can not be used.
39 */
40
41/**
42 * @ingroup bulksend
43 *
44 * @brief Send as much traffic as possible, trying to fill the bandwidth.
45 *
46 * This traffic generator simply sends data
47 * as fast as possible up to MaxBytes or until
48 * the application is stopped (if MaxBytes is
49 * zero). Once the lower layer send buffer is
50 * filled, it waits until space is free to
51 * send more data, essentially keeping a
52 * constant flow of data. Only SOCK_STREAM
53 * and SOCK_SEQPACKET sockets are supported.
54 * For example, TCP sockets can be used, but
55 * UDP sockets can not be used.
56 *
57 * If the attribute "EnableSeqTsSizeHeader" is enabled, the application will
58 * use some bytes of the payload to store an header with a sequence number,
59 * a timestamp, and the size of the packet sent. Support for extracting
60 * statistics from this header have been added to \c ns3::PacketSink
61 * (enable its "EnableSeqTsSizeHeader" attribute), or users may extract
62 * the header via trace sources.
63 */
65{
66 public:
67 /**
68 * @brief Get the type ID.
69 * @return the object TypeId
70 */
71 static TypeId GetTypeId();
72
74 ~BulkSendApplication() override;
75
76 /**
77 * @brief Set the upper bound for the total number of bytes to send.
78 *
79 * Once this bound is reached, no more application bytes are sent. If the
80 * application is stopped during the simulation and restarted, the
81 * total number of bytes sent is not reset; however, the maxBytes
82 * bound is still effective and the application will continue sending
83 * up to maxBytes. The value zero for maxBytes means that
84 * there is no upper bound; i.e. data is sent until the application
85 * or simulation is stopped.
86 *
87 * @param maxBytes the upper bound of bytes to send
88 */
89 void SetMaxBytes(uint64_t maxBytes);
90
91 private:
92 void DoStartApplication() override;
93 void DoConnectionSucceeded(Ptr<Socket> socket) override;
94 void CancelEvents() override;
95
96 /**
97 * @brief Send data until the L4 transmission buffer is full.
98 * @param from From address
99 * @param to To address
100 */
101 void SendData(const Address& from, const Address& to);
102
103 uint32_t m_sendSize; //!< Size of data to send each time
104 uint64_t m_maxBytes; //!< Limit total number of bytes sent
105 uint64_t m_totBytes{0}; //!< Total bytes sent so far
106 uint32_t m_seq{0}; //!< Sequence
107 Ptr<Packet> m_unsentPacket; //!< Variable to cache unsent packet
108 bool m_enableSeqTsSizeHeader{false}; //!< Enable or disable the SeqTsSizeHeader
109
110 /// Traced Callback: retransmitted packets
112 const TcpHeader&,
113 const Address&,
114 const Address&,
117
118 /// Callback for tracing the packet Tx events, includes source, destination, the packet sent,
119 /// and header
122
123 /**
124 * @brief Send more data as soon as some has been transmitted.
125 *
126 * Used in socket's SetSendCallback - params are forced by it.
127 *
128 * @param socket socket to use
129 * @param unused actually unused
130 */
131 void DataSend(Ptr<Socket> socket, uint32_t unused);
132
133 /**
134 * @brief Packet retransmitted (called by TcpSocketBase sockets via callback)
135 * @param p the retransmitted packet
136 * @param header the TCP header
137 * @param localAddr the local address
138 * @param peerAddr the peer address
139 * @param socket the socket that retransmitted the packet
140 */
142 const TcpHeader& header,
143 const Address& localAddr,
144 const Address& peerAddr,
146};
147
148} // namespace ns3
149
150#endif /* BULK_SEND_APPLICATION_H */
a polymophic address class
Definition address.h:90
bool m_enableSeqTsSizeHeader
Enable or disable the SeqTsSizeHeader.
void SendData(const Address &from, const Address &to)
Send data until the L4 transmission buffer is full.
Ptr< Packet > m_unsentPacket
Variable to cache unsent packet.
void PacketRetransmitted(Ptr< const Packet > p, const TcpHeader &header, const Address &localAddr, const Address &peerAddr, Ptr< const TcpSocketBase > socket)
Packet retransmitted (called by TcpSocketBase sockets via callback).
void DoStartApplication() override
Application specific startup code for child subclasses.
void CancelEvents() override
Cancel all pending events.
static TypeId GetTypeId()
Get the type ID.
TracedCallback< Ptr< const Packet >, const TcpHeader &, const Address &, const Address &, Ptr< const TcpSocketBase > > m_retransmissionTrace
Traced Callback: retransmitted packets.
uint32_t m_sendSize
Size of data to send each time.
uint64_t m_maxBytes
Limit total number of bytes sent.
void DoConnectionSucceeded(Ptr< Socket > socket) override
Application specific code for child subclasses upon a Connection Succeed event.
uint64_t m_totBytes
Total bytes sent so far.
void DataSend(Ptr< Socket > socket, uint32_t unused)
Send more data as soon as some has been transmitted.
void SetMaxBytes(uint64_t maxBytes)
Set the upper bound for the total number of bytes to send.
TracedCallback< Ptr< const Packet >, const Address &, const Address &, const SeqTsSizeHeader & > m_txTraceWithSeqTsSize
Callback for tracing the packet Tx events, includes source, destination, the packet sent,...
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
Header with a sequence, a timestamp, and a "size" attribute.
SourceApplication(bool allowPacketSocket=true)
Constructor.
Header for the Transmission Control Protocol.
Definition tcp-header.h:36
A base class for implementation of a stream socket using TCP.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.