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"
50 .SetGroupName(
"Network")
53 "A packet has been received",
55 "ns3::Packet::AddressTracedCallback");
118 while ((packet = socket->
RecvFrom(from)))
125 << packet->
GetSize() <<
" bytes from "
a polymophic address class
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
an address for a packet socket
static bool IsMatchingType(const Address &address)
static PacketSocketAddress ConvertFrom(const Address &address)
A server using PacketSocket.
uint32_t m_bytesRx
Total bytes received.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
Ptr< Socket > m_socket
Socket.
void StopApplication() override
Application specific shutdown code.
bool m_localAddressSet
Sanity check.
uint32_t m_pktRx
The number of received packets.
~PacketSocketServer() override
static TypeId GetTypeId()
Get the type ID.
void StartApplication() override
Application specific startup code.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
void DoDispose() override
Destructor implementation.
PacketSocketAddress m_localAddress
Local address.
static Time Now()
Return the current simulation virtual time.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
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...
virtual int Close()=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
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.
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.
#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_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.
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...