23 #include "ns3/ipv4-address.h"
24 #include "ns3/nstime.h"
25 #include "ns3/inet-socket-address.h"
26 #include "ns3/inet6-socket-address.h"
27 #include "ns3/socket.h"
28 #include "ns3/simulator.h"
29 #include "ns3/socket-factory.h"
30 #include "ns3/packet.h"
31 #include "ns3/uinteger.h"
32 #include "packet-loss-counter.h"
34 #include "seq-ts-header.h"
35 #include "udp-server.h"
40 NS_OBJECT_ENSURE_REGISTERED (UdpServer);
44 UdpServer::GetTypeId (
void)
46 static TypeId tid = TypeId (
"ns3::UdpServer")
47 .SetParent<Application> ()
48 .AddConstructor<UdpServer> ()
49 .AddAttribute (
"Port",
50 "Port on which we listen for incoming packets.",
52 MakeUintegerAccessor (&UdpServer::m_port),
53 MakeUintegerChecker<uint16_t> ())
54 .AddAttribute (
"PacketWindowSize",
55 "The size of the window used to compute the packet loss. This value should be a multiple of 8.",
59 MakeUintegerChecker<uint16_t> (8,256))
64 UdpServer::UdpServer ()
71 UdpServer::~UdpServer ()
80 return m_lossCounter.GetBitMapSize ();
87 m_lossCounter.SetBitMapSize (size);
94 return m_lossCounter.GetLost ();
122 m_socket->
Bind (local);
133 m_socket6->
Bind (local);
157 while ((packet = socket->
RecvFrom (from)))
163 uint32_t currentSequenceNumber = seqTs.
GetSeq ();
168 " Sequence Number: " << currentSequenceNumber <<
169 " Uid: " << packet->
GetUid () <<
170 " TXtime: " << seqTs.
GetTs () <<
178 " Sequence Number: " << currentSequenceNumber <<
179 " Uid: " << packet->
GetUid () <<
180 " TXtime: " << seqTs.
GetTs () <<
185 m_lossCounter.NotifyReceived (currentSequenceNumber);
uint32_t RemoveHeader(Header &header)
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
Ipv4Address GetIpv4(void) const
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
uint16_t GetPacketWindowSize() const
uint32_t GetLost(void) const
uint64_t GetUid(void) const
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss. This value should be a multiple of 8...
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
a polymophic address class
virtual void StartApplication(void)
Application specific startup code.
Ptr< Node > GetNode() const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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)
virtual void StopApplication(void)
Application specific shutdown code.
virtual void DoDispose(void)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
static InetSocketAddress ConvertFrom(const Address &address)
Callback< R > MakeNullCallback(void)
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
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 DoDispose(void)
a unique identifier for an interface.
static bool IsMatchingType(const Address &address)
static TypeId LookupByName(std::string name)
uint32_t GetReceived(void) const
returns the number of received packets