|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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"
47 .SetGroupName(
"Network")
49 .AddAttribute (
"MaxPackets",
50 "The maximum number of packets the application will send (zero means infinite)",
53 MakeUintegerChecker<uint32_t> ())
54 .AddAttribute (
"Interval",
58 .AddAttribute (
"PacketSize",
59 "Size of packets generated (bytes).",
62 MakeUintegerChecker<uint32_t> ())
63 .AddAttribute (
"Priority",
64 "Priority assigned to the packets generated.",
68 MakeUintegerChecker<uint8_t> ())
69 .AddTraceSource (
"Tx",
"A packet has been sent",
71 "ns3::Packet::AddressTracedCallback")
161 std::stringstream peerAddressStringStream;
168 << peerAddressStringStream.str () <<
" Uid: "
169 << p->
GetUid () <<
" Time: "
175 << peerAddressStringStream.str ());
TracedCallback< Ptr< const Packet >, const Address & > m_txTrace
Traced Callback: sent packets, source address.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
An identifier for simulation events.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Send(void)
Send a packet.
PacketSocketAddress m_peerAddress
Remote peer address.
virtual void StartApplication(void)
Application specific startup code.
an address for a packet socket
virtual void DoDispose(void)
Destructor implementation.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< Socket > m_socket
Socket.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Callback< R, Ts... > MakeNullCallback(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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.
uint8_t GetPriority(void) const
Query the priority value of this socket.
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...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual ~PacketSocketClient()
virtual int Close(void)=0
Close a socket.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void StopApplication(void)
Application specific shutdown code.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Time m_interval
Packet inter-send time.
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
bool m_peerAddressSet
Sanity check.
void SetPriority(uint8_t priority)
Manually set the socket priority.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
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...
uint32_t m_sent
Counter for sent packets.
static TypeId GetTypeId(void)
Get the type ID.
EventId m_sendEvent
Event to send the next packet.
uint32_t m_maxPackets
Maximum number of packets the application will send.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
The base class for all ns3 applications.
void SetPriority(uint8_t priority)
Manually set the socket priority.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
uint32_t m_size
Size of the sent packet.
static PacketSocketAddress ConvertFrom(const Address &address)
uint8_t m_priority
Priority of the sent packets.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
uint64_t GetUid(void) const
Returns the packet's Uid.
virtual void DoDispose(void)
Destructor implementation.