22 #include "ns3/address.h"
24 #include "ns3/nstime.h"
25 #include "ns3/socket.h"
26 #include "ns3/simulator.h"
27 #include "ns3/socket-factory.h"
28 #include "ns3/packet.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/trace-source-accessor.h"
31 #include "ns3/tcp-socket-factory.h"
45 .AddConstructor<BulkSendApplication> ()
46 .AddAttribute (
"SendSize",
"The amount of data to send each time.",
49 MakeUintegerChecker<uint32_t> (1))
50 .AddAttribute (
"Remote",
"The address of the destination",
53 MakeAddressChecker ())
54 .AddAttribute (
"MaxBytes",
55 "The total number of bytes to send. "
56 "Once these bytes are sent, "
57 "no data is sent again. The value zero means "
58 "that there is no limit.",
61 MakeUintegerChecker<uint32_t> ())
62 .AddAttribute (
"Protocol",
"The type of protocol to use.",
66 .AddTraceSource (
"Tx",
"A new packet is created and is sent",
124 NS_FATAL_ERROR (
"Using BulkSend with an incompatible socket type. "
125 "BulkSend requires SOCK_STREAM or SOCK_SEQPACKET. "
126 "In other words, use TCP instead of UDP.");
163 NS_LOG_WARN (
"BulkSendApplication found null socket to close in StopApplication");
193 if ((
unsigned)actual != toSend)
209 NS_LOG_LOGIC (
"BulkSendApplication Connection succeeded");
217 NS_LOG_LOGIC (
"BulkSendApplication, Connection Failed");
virtual ~BulkSendApplication()
void SendData()
Send data until the L4 transmission buffer is full.
uint32_t m_totBytes
Total bytes sent so far.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket.
void ConnectionFailed(Ptr< Socket > socket)
Connection Failed (called by Socket through a callback)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual int ShutdownRecv(void)=0
uint32_t m_maxBytes
Limit total number of bytes sent.
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void StopApplication(void)
Application specific shutdown code.
The base class for all ns3 applications.
virtual void StartApplication(void)
Application specific startup code.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
hold objects of type ns3::TypeId
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetMaxBytes(uint32_t maxBytes)
Set the upper bound for the total number of bytes to send.
void DataSend(Ptr< Socket >, uint32_t)
Send more data as soon as some has been transmitted.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual enum Socket::SocketType GetSocketType(void) const =0
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
TypeId m_tid
The type of protocol to use.
static TypeId GetTypeId(void)
Get the type ID.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
static Time Now(void)
Return the "current simulation time".
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
Ptr< Socket > m_socket
Associated socket.
void ConnectionSucceeded(Ptr< Socket > socket)
Connection Succeeded (called by Socket through a callback)
hold objects of type ns3::Address
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
bool m_connected
True if connected.
Address m_peer
Peer address.
static bool IsMatchingType(const Address &addr)
If the address match.
static TypeId GetTypeId(void)
Get the type ID.
void SetConnectCallback(Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
Specify callbacks to allow the caller to determine if the connection succeeds of fails.
uint32_t m_sendSize
Size of data to send each time.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
Ptr< Socket > GetSocket(void) const
Get the socket this application is attached to.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: sent packets.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
static bool IsMatchingType(const Address &address)