11#include "ns3/boolean.h" 
   14#include "ns3/nstime.h" 
   15#include "ns3/packet.h" 
   16#include "ns3/simulator.h" 
   17#include "ns3/socket-factory.h" 
   18#include "ns3/socket.h" 
   19#include "ns3/tcp-socket-base.h" 
   20#include "ns3/tcp-socket-factory.h" 
   21#include "ns3/trace-source-accessor.h" 
   22#include "ns3/uinteger.h" 
   35        TypeId(
"ns3::BulkSendApplication")
 
   37            .SetGroupName(
"Applications")
 
   39            .AddAttribute(
"SendSize",
 
   40                          "The amount of data to send each time.",
 
   44            .AddAttribute(
"MaxBytes",
 
   45                          "The total number of bytes to send. " 
   46                          "Once these bytes are sent, " 
   47                          "no data  is sent again. The value zero means " 
   48                          "that there is no limit.",
 
   52            .AddAttribute(
"Protocol",
 
   53                          "The type of protocol to use.",
 
   57            .AddAttribute(
"EnableSeqTsSizeHeader",
 
   58                          "Add SeqTsSizeHeader to each packet",
 
   62            .AddTraceSource(
"TxWithSeqTsSize",
 
   63                            "A new packet is created with SeqTsSizeHeader",
 
   65                            "ns3::PacketSink::SeqTsSizeCallback")
 
   66            .AddTraceSource(
"TcpRetransmission",
 
   67                            "The TCP socket retransmitted a packet",
 
   69                            "ns3::TcpSocketBase::RetransmissionCallback");
 
 
  108        NS_FATAL_ERROR(
"Using BulkSend with an incompatible socket type. " 
  109                       "BulkSend requires SOCK_STREAM or SOCK_SEQPACKET. " 
  110                       "In other words, use TCP instead of UDP.");
 
  118        tcpSocket->TraceConnectWithoutContext(
 
 
  157            toSend = packet->GetSize();
 
  168            packet->AddHeader(header);
 
  175        int actual = 
m_socket->Send(packet);
 
  176        if ((
unsigned)actual == toSend)
 
  182        else if (actual == -1)
 
  187            NS_LOG_DEBUG(
"Unable to send packet; caching for later attempt");
 
  191        else if (actual > 0 && (
unsigned)actual < toSend)
 
  196            NS_LOG_DEBUG(
"Packet size: " << packet->GetSize() << 
"; sent: " << actual
 
  197                                         << 
"; fragment saved: " << toSend - (
unsigned)actual);
 
  198            Ptr<Packet> sent = packet->CreateFragment(0, actual);
 
  199            Ptr<Packet> unsent = packet->CreateFragment(actual, (toSend - (
unsigned)actual));
 
 
  222    NS_LOG_LOGIC(
"BulkSendApplication Connection succeeded");
 
  225    socket->GetSockName(from);
 
  226    socket->GetPeerName(to);
 
 
  239        socket->GetSockName(from);
 
  240        socket->GetPeerName(to);
 
 
  252    NS_LOG_FUNCTION(
this << p << header << localAddr << peerAddr << socket);
 
 
a polymophic address class
 
AttributeValue implementation for Boolean.
 
Send as much traffic as possible, trying to fill the bandwidth.
 
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.
 
~BulkSendApplication() override
 
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.
 
static Time Now()
Return the current simulation virtual time.
 
TypeId m_protocolTid
Protocol TypeId value.
 
SourceApplication(bool allowPacketSocket=true)
Constructor.
 
Ptr< Socket > m_socket
Socket.
 
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
 
bool m_connected
flag whether socket is connected
 
Address m_peer
Peer address.
 
static TypeId GetTypeId()
Get the type ID.
 
a unique identifier for an interface.
 
TypeId SetParent(TypeId tid)
Set the parent TypeId.
 
AttributeValue implementation for TypeId.
 
Hold an unsigned integer type.
 
Ptr< const AttributeChecker > MakeBooleanChecker()
 
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
 
Ptr< const AttributeChecker > MakeTypeIdChecker()
 
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
 
Ptr< const AttributeChecker > MakeUintegerChecker()
 
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
 
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
 
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
 
#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 an Object subclass with the TypeId system.
 
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
 
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.