|
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 .AddTraceSource (
"Rx",
"A packet has been received",
51 "ns3::Packet::AddressTracedCallback")
115 while ((packet = socket->
RecvFrom (from)))
122 <<
" packet sink received "
123 << packet->
GetSize () <<
" bytes from "
125 <<
" total Rx " <<
m_pktRx <<
" packets"
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.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoDispose(void)
Destructor implementation.
an address for a packet socket
virtual void DoDispose(void)
Destructor implementation.
A server using PacketSocket.
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.
static bool IsMatchingType(const Address &address)
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
a polymophic address class
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual void StartApplication(void)
Application specific startup code.
virtual int Close(void)=0
Close a socket.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
bool m_localAddressSet
Sanity check.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
virtual ~PacketSocketServer()
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
virtual void StopApplication(void)
Application specific shutdown code.
uint32_t m_pktRx
The number of received packets.
PacketSocketAddress m_localAddress
Local address.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint32_t m_bytesRx
Total bytes received.
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...
Ptr< Socket > m_socket
Socket.
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
The base class for all ns3 applications.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
static TypeId LookupByName(std::string name)
Get a TypeId by name.
static PacketSocketAddress ConvertFrom(const Address &address)