From 4b39fb88ae02dfaa60eb4da56a386bbf619f0553 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 17 Mar 2007 23:16:59 -0700 Subject: [PATCH] Rename UdpSocket to DatagramSocket --- SConstruct | 4 +-- samples/main-simple-p2p.cc | 14 ++++---- samples/main-simple.cc | 14 ++++---- samples/ns-2/simple.cc | 18 +++++----- .../{udp-socket.cc => datagram-socket.cc} | 34 +++++++++---------- src/node/{udp-socket.h => datagram-socket.h} | 14 ++++---- src/node/udp-end-point.cc | 4 +-- src/node/udp-end-point.h | 8 ++--- src/node/udp.cc | 4 +-- 9 files changed, 57 insertions(+), 57 deletions(-) rename src/node/{udp-socket.cc => datagram-socket.cc} (77%) rename src/node/{udp-socket.h => datagram-socket.h} (88%) diff --git a/SConstruct b/SConstruct index 081afc998..ef3ca6ab9 100644 --- a/SConstruct +++ b/SConstruct @@ -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', diff --git a/samples/main-simple-p2p.cc b/samples/main-simple-p2p.cc index 5a58af542..6b1d3a09d 100644 --- a/samples/main-simple-p2p.cc +++ b/samples/main-simple-p2p.cc @@ -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); diff --git a/samples/main-simple.cc b/samples/main-simple.cc index 5e47d740e..c41f26630 100644 --- a/samples/main-simple.cc +++ b/samples/main-simple.cc @@ -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); diff --git a/samples/ns-2/simple.cc b/samples/ns-2/simple.cc index 003dc698f..ba016f200 100644 --- a/samples/ns-2/simple.cc +++ b/samples/ns-2/simple.cc @@ -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); diff --git a/src/node/udp-socket.cc b/src/node/datagram-socket.cc similarity index 77% rename from src/node/udp-socket.cc rename to src/node/datagram-socket.cc index 306f3fbba..82cfe0f76 100644 --- a/src/node/udp-socket.cc +++ b/src/node/datagram-socket.cc @@ -18,7 +18,7 @@ * * Author: Mathieu Lacage */ -#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 cb) { m_dummyRxCallback = cb; } void -UdpSocket::SetRxCallback (Callback cb) { @@ -146,7 +146,7 @@ UdpSocket::SetRxCallback (CallbackGetUdp (); } Node * -UdpSocket::GetNode (void) const +DatagramSocket::GetNode (void) const { return m_node; } diff --git a/src/node/udp-socket.h b/src/node/datagram-socket.h similarity index 88% rename from src/node/udp-socket.h rename to src/node/datagram-socket.h index fcf3fde88..5addf22f0 100644 --- a/src/node/udp-socket.h +++ b/src/node/datagram-socket.h @@ -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 cb); + void SetDummyRxCallback (Callback 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 cb); + void SetRxCallback (Callback cb); /** * Return pointer to node */ @@ -129,8 +129,8 @@ private: Node *m_node; Ipv4Address m_defaultAddress; uint16_t m_defaultPort; - Callback m_dummyRxCallback; - Callback m_rxCallback; + Callback m_dummyRxCallback; + Callback m_rxCallback; }; }//namespace ns3 diff --git a/src/node/udp-end-point.cc b/src/node/udp-end-point.cc index 48adb3661..c7ac63a5a 100644 --- a/src/node/udp-end-point.cc +++ b/src/node/udp-end-point.cc @@ -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; diff --git a/src/node/udp-end-point.h b/src/node/udp-end-point.h index b0d745ce7..bdfc1430f 100644 --- a/src/node/udp-end-point.h +++ b/src/node/udp-end-point.h @@ -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 diff --git a/src/node/udp.cc b/src/node/udp.cc index f1f0fef29..a7dd2d75e 100644 --- a/src/node/udp.cc +++ b/src/node/udp.cc @@ -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); }