22 #include "ns3/nstime.h"
23 #include "ns3/packet-socket-address.h"
24 #include "ns3/packet-socket.h"
25 #include "ns3/packet-socket-factory.h"
26 #include "ns3/socket.h"
27 #include "ns3/simulator.h"
28 #include "ns3/socket-factory.h"
29 #include "ns3/packet.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/abort.h"
46 .AddConstructor<PacketSocketClient> ()
47 .AddAttribute (
"MaxPackets",
48 "The maximum number of packets the application will send (zero means infinite)",
51 MakeUintegerChecker<uint32_t> ())
52 .AddAttribute (
"Interval",
56 .AddAttribute (
"PacketSize",
57 "Size of packets generated (bytes).",
60 MakeUintegerChecker<uint32_t> ())
61 .AddTraceSource (
"Tx",
"A packet has been sent",
131 std::stringstream peerAddressStringStream;
137 << peerAddressStringStream.str () <<
" Uid: "
138 << p->GetUid () <<
" Time: "
144 << peerAddressStringStream.str ());
uint32_t m_maxPackets
Maximum number of packets the application will send.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void StopApplication(void)
Application specific shutdown code.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
an address for a packet socket
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool m_peerAddressSet
Sanity check.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Callback< R > MakeNullCallback(void)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual ~PacketSocketClient()
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t m_sent
Counter for sent packets.
Time m_interval
Packet inter-send time.
virtual void StartApplication(void)
Application specific startup code.
The base class for all ns3 applications.
EventId m_sendEvent
Event to send the next packet.
Attribute for objects of type ns3::Time.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
static TypeId GetTypeId(void)
Get the type ID.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
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...
Ptr< Socket > m_socket
Socket.
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)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
static Time Now(void)
Return the "current simulation time".
TracedCallback< Ptr< const Packet >, const Address & > m_txTrace
Traced Callback: sent packets, source address.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
an identifier for simulation events.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Time Seconds(double value)
Construct a Time in the indicated unit.
void Send(void)
Send a packet.
static PacketSocketAddress ConvertFrom(const Address &address)
PacketSocketAddress m_peerAddress
Remote peer address.
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.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
uint32_t m_size
Size of the sent packet.
static TypeId LookupByName(std::string name)