26 #include "ns3/abort.h"
28 #include "ns3/nstime.h"
29 #include "ns3/packet.h"
30 #include "ns3/simulator.h"
31 #include "ns3/socket-factory.h"
32 #include "ns3/socket.h"
33 #include "ns3/uinteger.h"
49 TypeId(
"ns3::PacketSocketClient")
51 .SetGroupName(
"Network")
55 "The maximum number of packets the application will send (zero means infinite)",
58 MakeUintegerChecker<uint32_t>())
59 .AddAttribute(
"Interval",
60 "The time to wait between packets",
64 .AddAttribute(
"PacketSize",
65 "Size of packets generated (bytes).",
68 MakeUintegerChecker<uint32_t>())
69 .AddAttribute(
"Priority",
70 "Priority assigned to the packets generated.",
74 MakeUintegerChecker<uint8_t>())
76 "A packet has been sent",
78 "ns3::Packet::AddressTracedCallback");
167 std::stringstream peerAddressStringStream;
173 NS_LOG_INFO(
"TraceDelay TX " <<
m_size <<
" bytes to " << peerAddressStringStream.str()
174 <<
" Uid: " << p->
GetUid()
180 << peerAddressStringStream.str());
190 "Generating infinite packets at the same time does not seem to be a good idea");
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
An identifier for simulation events.
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
uint64_t GetUid() const
Returns the packet's Uid.
an address for a packet socket
static PacketSocketAddress ConvertFrom(const Address &address)
uint32_t m_sent
Counter for sent packets.
void StopApplication() override
Application specific shutdown code.
TracedCallback< Ptr< const Packet >, const Address & > m_txTrace
Traced Callback: sent packets, source address.
Ptr< Socket > m_socket
Socket.
void DoDispose() override
Destructor implementation.
void Send()
Send a packet.
uint8_t GetPriority() const
Query the priority value of this socket.
EventId m_sendEvent
Event to send the next packet.
uint32_t m_maxPackets
Maximum number of packets the application will send.
void SetPriority(uint8_t priority)
Manually set the socket priority.
static TypeId GetTypeId()
Get the type ID.
~PacketSocketClient() override
bool m_peerAddressSet
Sanity check.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
uint32_t m_size
Size of the sent packet.
uint8_t m_priority
Priority of the sent packets.
void StartApplication() override
Application specific startup code.
PacketSocketAddress m_peerAddress
Remote peer address.
Time m_interval
Packet inter-send time.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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...
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
void SetPriority(uint8_t priority)
Manually set the socket priority.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
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 int Close()=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
bool IsZero() const
Exactly equivalent to t == 0.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Callback< R, Args... > MakeNullCallback()
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
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.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)