20 #include "ns3/address.h" 
   21 #include "ns3/address-utils.h" 
   23 #include "ns3/inet-socket-address.h" 
   24 #include "ns3/inet6-socket-address.h" 
   26 #include "ns3/socket.h" 
   27 #include "ns3/udp-socket.h" 
   28 #include "ns3/simulator.h" 
   29 #include "ns3/socket-factory.h" 
   30 #include "ns3/packet.h" 
   31 #include "ns3/trace-source-accessor.h" 
   32 #include "ns3/udp-socket-factory.h" 
   46     .SetGroupName(
"Applications")
 
   48     .AddAttribute (
"Local",
 
   49                    "The Address on which to Bind the rx socket.",
 
   53     .AddAttribute (
"Protocol",
 
   54                    "The type id of the protocol to use for the rx socket.",
 
   58     .AddTraceSource (
"Rx",
 
   59                      "A packet has been received",
 
   61                      "ns3::Packet::AddressTracedCallback")
 
   91 std::list<Ptr<Socket> >
 
  126               udpSocket->MulticastJoinGroup (0, 
m_local);
 
  151       acceptedSocket->
Close ();
 
  165   while ((packet = socket->
RecvFrom (from)))
 
  175                        << 
"s packet sink received " 
  176                        <<  packet->
GetSize () << 
" bytes from " 
  179                        << 
" total Rx " << 
m_totalRx << 
" bytes");
 
  184                        << 
"s packet sink received " 
  185                        <<  packet->
GetSize () << 
" bytes from " 
  188                        << 
" total Rx " << 
m_totalRx << 
" bytes");
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Ipv6Address GetIpv6(void) const 
Get the IPv6 address. 
 
Ipv4Address GetIpv4(void) const 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
Address m_local
Local address to bind to. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
uint32_t m_totalRx
Total bytes received. 
 
virtual int ShutdownSend(void)=0
 
bool IsMulticast(const Address &ad)
Address family-independent test for a multicast address. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address. 
 
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
 
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error. 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Callback< R > MakeNullCallback(void)
 
a polymophic address class 
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source. 
 
virtual int Listen(void)=0
Listen for incoming connections. 
 
Ptr< const AttributeAccessor > MakeAddressAccessor(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. 
 
Ptr< Node > GetNode() const 
 
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application. 
 
AttributeValue implementation for TypeId. 
 
TypeId m_tid
Protocol TypeId. 
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
virtual void StopApplication(void)
Application specific shutdown code. 
 
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...
 
void HandlePeerClose(Ptr< Socket > socket)
Handle an connection close. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address. 
 
Ptr< const AttributeChecker > MakeAddressChecker(void)
 
static Time Now(void)
Return the current simulation virtual time. 
 
uint32_t GetTotalRx() const 
 
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts. 
 
std::list< Ptr< Socket > > GetAcceptedSockets(void) const 
 
std::list< Ptr< Socket > > m_socketList
the accepted sockets 
 
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
AttributeValue implementation for Address. 
 
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an incoming connection. 
 
void HandlePeerError(Ptr< Socket > socket)
Handle an connection error. 
 
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress. 
 
static bool IsMatchingType(const Address &addr)
If the address match. 
 
uint16_t GetPort(void) const 
Get the port. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
uint16_t GetPort(void) const 
 
virtual void StartApplication(void)
Application specific startup code. 
 
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. 
 
Receive and consume traffic generated to an IP address and port. 
 
Ptr< Socket > m_socket
Listening socket. 
 
virtual int Close(void)=0
Close a socket. 
 
Ptr< const AttributeChecker > MakeTypeIdChecker(void)
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
static bool IsMatchingType(const Address &address)
 
Ptr< Socket > GetListeningSocket(void) const