Rename UdpSocket to DatagramSocket
This commit is contained in:
@@ -185,7 +185,7 @@ node.add_sources ([
|
||||
'ipv4.cc',
|
||||
'ipv4-end-point.cc',
|
||||
'udp-end-point.cc',
|
||||
'udp-socket.cc',
|
||||
'datagram-socket.cc',
|
||||
'udp.cc',
|
||||
'arp-header.cc',
|
||||
'application.cc',
|
||||
@@ -220,7 +220,7 @@ node.add_headers ([
|
||||
node.add_inst_headers ([
|
||||
'node.h',
|
||||
'internet-node.h',
|
||||
'udp-socket.h',
|
||||
'datagram-socket.h',
|
||||
'ipv4-address.h',
|
||||
'net-device.h',
|
||||
'arp-ipv4-interface.h',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "ns3/internet-node.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/udp-socket.h"
|
||||
#include "ns3/datagram-socket.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "ns3/p2p-channel.h"
|
||||
#include "ns3/p2p-net-device.h"
|
||||
@@ -15,7 +15,7 @@ using namespace ns3;
|
||||
|
||||
|
||||
static void
|
||||
GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
GenerateTraffic (DatagramSocket *socket, uint32_t size)
|
||||
{
|
||||
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
|
||||
socket->SendDummy (size);
|
||||
@@ -26,15 +26,15 @@ GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
}
|
||||
|
||||
static void
|
||||
UdpSocketPrinter (UdpSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
DatagramSocketPrinter (DatagramSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
{
|
||||
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << size << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
PrintTraffic (UdpSocket *socket)
|
||||
PrintTraffic (DatagramSocket *socket)
|
||||
{
|
||||
socket->SetDummyRxCallback (MakeCallback (&UdpSocketPrinter));
|
||||
socket->SetDummyRxCallback (MakeCallback (&DatagramSocketPrinter));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -94,9 +94,9 @@ int main (int argc, char *argv[])
|
||||
|
||||
AddP2PLink (a, b);
|
||||
|
||||
UdpSocket *sink = new UdpSocket (a);
|
||||
DatagramSocket *sink = new DatagramSocket (a);
|
||||
sink->Bind (80);
|
||||
UdpSocket *source = new UdpSocket (b);
|
||||
DatagramSocket *source = new DatagramSocket (b);
|
||||
source->SetDefaultDestination (Ipv4Address ("192.168.0.2"), 80);
|
||||
|
||||
GenerateTraffic (source, 500);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "ns3/internet-node.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/udp-socket.h"
|
||||
#include "ns3/datagram-socket.h"
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
using namespace ns3;
|
||||
@@ -31,7 +31,7 @@ SmallTests (void)
|
||||
}
|
||||
|
||||
static void
|
||||
GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
GenerateTraffic (DatagramSocket *socket, uint32_t size)
|
||||
{
|
||||
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
|
||||
socket->SendDummy (size);
|
||||
@@ -42,15 +42,15 @@ GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
}
|
||||
|
||||
static void
|
||||
UdpSocketPrinter (UdpSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
DatagramSocketPrinter (DatagramSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
{
|
||||
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << size << std::endl;
|
||||
}
|
||||
|
||||
static void
|
||||
PrintTraffic (UdpSocket *socket)
|
||||
PrintTraffic (DatagramSocket *socket)
|
||||
{
|
||||
socket->SetDummyRxCallback (MakeCallback (&UdpSocketPrinter));
|
||||
socket->SetDummyRxCallback (MakeCallback (&DatagramSocketPrinter));
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
@@ -59,10 +59,10 @@ int main (int argc, char *argv[])
|
||||
|
||||
InternetNode *a = new InternetNode ();
|
||||
|
||||
UdpSocket *sink = new UdpSocket (a);
|
||||
DatagramSocket *sink = new DatagramSocket (a);
|
||||
sink->Bind (80);
|
||||
|
||||
UdpSocket *source = new UdpSocket (a);
|
||||
DatagramSocket *source = new DatagramSocket (a);
|
||||
source->SetDefaultDestination (Ipv4Address::GetLoopback (), 80);
|
||||
|
||||
GenerateTraffic (source, 500);
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/arp-ipv4-interface.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/udp-socket.h"
|
||||
#include "ns3/datagram-socket.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
#include "ns3/drop-tail.h"
|
||||
#include "ns3/trace-writer.h"
|
||||
@@ -147,7 +147,7 @@ protected:
|
||||
|
||||
|
||||
static void
|
||||
GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
GenerateTraffic (DatagramSocket *socket, uint32_t size)
|
||||
{
|
||||
std::cout << "Node: " << socket->GetNode()->GetId ()
|
||||
<< " at=" << Simulator::Now ().GetSeconds () << "s,"
|
||||
@@ -160,7 +160,7 @@ GenerateTraffic (UdpSocket *socket, uint32_t size)
|
||||
}
|
||||
|
||||
static void
|
||||
UdpSocketPrinter (UdpSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
DatagramSocketPrinter (DatagramSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
|
||||
{
|
||||
std::cout << "Node: " << socket->GetNode()->GetId ()
|
||||
<< " at=" << Simulator::Now ().GetSeconds () << "s,"
|
||||
@@ -168,9 +168,9 @@ UdpSocketPrinter (UdpSocket *socket, uint32_t size, Ipv4Address from, uint16_t f
|
||||
}
|
||||
|
||||
static void
|
||||
PrintTraffic (UdpSocket *socket)
|
||||
PrintTraffic (DatagramSocket *socket)
|
||||
{
|
||||
socket->SetDummyRxCallback (MakeCallback (&UdpSocketPrinter));
|
||||
socket->SetDummyRxCallback (MakeCallback (&DatagramSocketPrinter));
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -315,11 +315,11 @@ int main (int argc, char *argv[])
|
||||
traceContainer, channelName);
|
||||
SetupTrace (traceContainer, tracer);
|
||||
|
||||
UdpSocket *source0 = new UdpSocket (n0);
|
||||
UdpSocket *source3 = new UdpSocket (n3);
|
||||
UdpSocket *sink3 = new UdpSocket(n3);
|
||||
DatagramSocket *source0 = new DatagramSocket (n0);
|
||||
DatagramSocket *source3 = new DatagramSocket (n3);
|
||||
DatagramSocket *sink3 = new DatagramSocket(n3);
|
||||
sink3->Bind (80);
|
||||
UdpSocket *sink1 = new UdpSocket(n1);
|
||||
DatagramSocket *sink1 = new DatagramSocket(n1);
|
||||
sink1->Bind (80);
|
||||
|
||||
source3->SetDefaultDestination (Ipv4Address ("10.1.2.1"), 80);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "udp-socket.h"
|
||||
#include "datagram-socket.h"
|
||||
#include "udp.h"
|
||||
#include "udp-end-point.h"
|
||||
#include "node.h"
|
||||
@@ -26,19 +26,19 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
UdpSocket::UdpSocket (Node *node)
|
||||
DatagramSocket::DatagramSocket (Node *node)
|
||||
: m_endPoint (0),
|
||||
m_node (node)
|
||||
{
|
||||
NS_ASSERT (GetUdp () != 0);
|
||||
}
|
||||
UdpSocket::~UdpSocket ()
|
||||
DatagramSocket::~DatagramSocket ()
|
||||
{
|
||||
delete m_endPoint;
|
||||
}
|
||||
|
||||
int
|
||||
UdpSocket::Bind (void)
|
||||
DatagramSocket::Bind (void)
|
||||
{
|
||||
m_endPoint = GetUdp ()->Allocate ();
|
||||
if (m_endPoint == 0)
|
||||
@@ -49,7 +49,7 @@ UdpSocket::Bind (void)
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
UdpSocket::Bind (Ipv4Address address)
|
||||
DatagramSocket::Bind (Ipv4Address address)
|
||||
{
|
||||
m_endPoint = GetUdp ()->Allocate (address);
|
||||
if (m_endPoint == 0)
|
||||
@@ -60,7 +60,7 @@ UdpSocket::Bind (Ipv4Address address)
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
UdpSocket::Bind (uint16_t port)
|
||||
DatagramSocket::Bind (uint16_t port)
|
||||
{
|
||||
m_endPoint = GetUdp ()->Allocate (port);
|
||||
if (m_endPoint == 0)
|
||||
@@ -71,7 +71,7 @@ UdpSocket::Bind (uint16_t port)
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
UdpSocket::Bind (Ipv4Address address, uint16_t port)
|
||||
DatagramSocket::Bind (Ipv4Address address, uint16_t port)
|
||||
{
|
||||
m_endPoint = GetUdp ()->Allocate (address, port);
|
||||
if (m_endPoint == 0)
|
||||
@@ -83,18 +83,18 @@ UdpSocket::Bind (Ipv4Address address, uint16_t port)
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::SetDefaultDestination (Ipv4Address daddr, uint16_t dport)
|
||||
DatagramSocket::SetDefaultDestination (Ipv4Address daddr, uint16_t dport)
|
||||
{
|
||||
m_defaultAddress = daddr;
|
||||
m_defaultPort = dport;
|
||||
}
|
||||
void
|
||||
UdpSocket::SendDummy (uint32_t size)
|
||||
DatagramSocket::SendDummy (uint32_t size)
|
||||
{
|
||||
SendDummyTo (size, m_defaultAddress, m_defaultPort);
|
||||
}
|
||||
void
|
||||
UdpSocket::SendDummyTo (uint32_t size, Ipv4Address daddr, uint16_t dport)
|
||||
DatagramSocket::SendDummyTo (uint32_t size, Ipv4Address daddr, uint16_t dport)
|
||||
{
|
||||
if (m_endPoint == 0)
|
||||
{
|
||||
@@ -110,12 +110,12 @@ UdpSocket::SendDummyTo (uint32_t size, Ipv4Address daddr, uint16_t dport)
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::Send (uint8_t const*buffer, uint32_t size)
|
||||
DatagramSocket::Send (uint8_t const*buffer, uint32_t size)
|
||||
{
|
||||
SendTo (buffer, size, m_defaultAddress, m_defaultPort);
|
||||
}
|
||||
void
|
||||
UdpSocket::SendTo (uint8_t const*buffer, uint32_t size,
|
||||
DatagramSocket::SendTo (uint8_t const*buffer, uint32_t size,
|
||||
Ipv4Address daddr, uint16_t dport)
|
||||
{
|
||||
if (m_endPoint == 0)
|
||||
@@ -131,14 +131,14 @@ UdpSocket::SendTo (uint8_t const*buffer, uint32_t size,
|
||||
m_endPoint->GetLocalPort (), dport);
|
||||
}
|
||||
void
|
||||
UdpSocket::SetDummyRxCallback (Callback<void,UdpSocket*,
|
||||
DatagramSocket::SetDummyRxCallback (Callback<void,DatagramSocket*,
|
||||
uint32_t,
|
||||
Ipv4Address,uint16_t> cb)
|
||||
{
|
||||
m_dummyRxCallback = cb;
|
||||
}
|
||||
void
|
||||
UdpSocket::SetRxCallback (Callback<void,UdpSocket*,
|
||||
DatagramSocket::SetRxCallback (Callback<void,DatagramSocket*,
|
||||
uint8_t const*,uint32_t,
|
||||
Ipv4Address,uint16_t> cb)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ UdpSocket::SetRxCallback (Callback<void,UdpSocket*,
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::ForwardUp (Packet &p, Ipv4Address saddr, uint16_t sport)
|
||||
DatagramSocket::ForwardUp (Packet &p, Ipv4Address saddr, uint16_t sport)
|
||||
{
|
||||
if (!m_dummyRxCallback.IsNull ())
|
||||
{
|
||||
@@ -159,13 +159,13 @@ UdpSocket::ForwardUp (Packet &p, Ipv4Address saddr, uint16_t sport)
|
||||
}
|
||||
|
||||
Udp *
|
||||
UdpSocket::GetUdp (void) const
|
||||
DatagramSocket::GetUdp (void) const
|
||||
{
|
||||
return m_node->GetUdp ();
|
||||
}
|
||||
|
||||
Node *
|
||||
UdpSocket::GetNode (void) const
|
||||
DatagramSocket::GetNode (void) const
|
||||
{
|
||||
return m_node;
|
||||
}
|
||||
@@ -39,14 +39,14 @@ class Udp;
|
||||
* one of the ::Send methods, the socket is implicitely
|
||||
* bound to a random port and to all interfaces.
|
||||
*/
|
||||
class UdpSocket
|
||||
class DatagramSocket
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Create an unbound udp socket.
|
||||
*/
|
||||
UdpSocket (Node *node);
|
||||
~UdpSocket ();
|
||||
DatagramSocket (Node *node);
|
||||
~DatagramSocket ();
|
||||
|
||||
/**
|
||||
* Allocate a free port number and
|
||||
@@ -106,14 +106,14 @@ public:
|
||||
* forwards to the application the number of bytes received and from who they
|
||||
* were received.
|
||||
*/
|
||||
void SetDummyRxCallback (Callback<void,UdpSocket*,uint32_t,Ipv4Address,uint16_t> cb);
|
||||
void SetDummyRxCallback (Callback<void,DatagramSocket*,uint32_t,Ipv4Address,uint16_t> cb);
|
||||
/**
|
||||
* When a packet is received by this socket, it invokes the "normal callback" which
|
||||
* forwards to the application the buffer of bytes received and from who they
|
||||
* were received. The application is responsible for copying that buffer if it wants
|
||||
* to keep track of it.
|
||||
*/
|
||||
void SetRxCallback (Callback<void,UdpSocket*,uint8_t const*,uint32_t,Ipv4Address,uint16_t> cb);
|
||||
void SetRxCallback (Callback<void,DatagramSocket*,uint8_t const*,uint32_t,Ipv4Address,uint16_t> cb);
|
||||
/**
|
||||
* Return pointer to node
|
||||
*/
|
||||
@@ -129,8 +129,8 @@ private:
|
||||
Node *m_node;
|
||||
Ipv4Address m_defaultAddress;
|
||||
uint16_t m_defaultPort;
|
||||
Callback<void,UdpSocket*,uint32_t,Ipv4Address,uint16_t> m_dummyRxCallback;
|
||||
Callback<void,UdpSocket*,uint8_t const*,uint32_t,Ipv4Address,uint16_t> m_rxCallback;
|
||||
Callback<void,DatagramSocket*,uint32_t,Ipv4Address,uint16_t> m_dummyRxCallback;
|
||||
Callback<void,DatagramSocket*,uint8_t const*,uint32_t,Ipv4Address,uint16_t> m_rxCallback;
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
@@ -28,11 +28,11 @@ UdpEndPoint::UdpEndPoint (Ipv4Address address, uint16_t port)
|
||||
{}
|
||||
|
||||
void
|
||||
UdpEndPoint::SetSocket (UdpSocket *socket)
|
||||
UdpEndPoint::SetSocket (DatagramSocket *socket)
|
||||
{
|
||||
m_socket = socket;
|
||||
}
|
||||
UdpSocket *
|
||||
DatagramSocket *
|
||||
UdpEndPoint::GetSocket (void) const
|
||||
{
|
||||
return m_socket;
|
||||
|
||||
@@ -27,17 +27,17 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class UdpSocket;
|
||||
class DatagramSocket;
|
||||
|
||||
class UdpEndPoint : public Ipv4EndPoint
|
||||
{
|
||||
public:
|
||||
UdpEndPoint (Ipv4Address address, uint16_t port);
|
||||
|
||||
void SetSocket (UdpSocket *socket);
|
||||
UdpSocket *GetSocket (void) const;
|
||||
void SetSocket (DatagramSocket *socket);
|
||||
DatagramSocket *GetSocket (void) const;
|
||||
private:
|
||||
UdpSocket *m_socket;
|
||||
DatagramSocket *m_socket;
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "udp-header.h"
|
||||
#include "ipv4-end-point-demux.h"
|
||||
#include "udp-end-point.h"
|
||||
#include "udp-socket.h"
|
||||
#include "datagram-socket.h"
|
||||
#include "node.h"
|
||||
#include "ipv4.h"
|
||||
#include "l3-demux.h"
|
||||
@@ -94,7 +94,7 @@ Udp::Receive(Packet& packet,
|
||||
{
|
||||
return;
|
||||
}
|
||||
UdpSocket *socket = endPoint->GetSocket ();
|
||||
DatagramSocket *socket = endPoint->GetSocket ();
|
||||
socket->ForwardUp (packet, source, udpHeader.GetSource ());
|
||||
NS_ASSERT (socket != 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user