Plumb in outbound SerialPhy
authortomh@ubuntu
Tue, 20 Feb 2007 23:58:21 -0800
changeset 310 03f09f4d1a8d
parent 309 0d4e578c5c5d
child 311 f0a9889dff3a
Plumb in outbound SerialPhy
samples/ns-2/simple.tcl.cc
src/node/serial-net-device.cc
src/node/serial-net-device.h
src/node/udp-socket.cc
src/node/udp-socket.h
--- a/samples/ns-2/simple.tcl.cc	Tue Feb 20 23:26:59 2007 -0800
+++ b/samples/ns-2/simple.tcl.cc	Tue Feb 20 23:58:21 2007 -0800
@@ -71,7 +71,7 @@
 static void
 GenerateTraffic (UdpSocket *socket, uint32_t size)
 {
-  std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
+  std::cout << "Node: " << socket->GetNode()->GetId () << " at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
   socket->SendDummy (size);
   if (size > 50)
     {
@@ -82,7 +82,7 @@
 static void
 UdpSocketPrinter (UdpSocket *socket, uint32_t size, Ipv4Address from, uint16_t fromPort)
 {
-  std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << size << std::endl;
+  std::cout << "Node: " << socket->GetNode()->GetId () << " at=" << Simulator::Now ().GetSeconds () << "s, rx bytes=" << size << std::endl;
 }
 
 static void
--- a/src/node/serial-net-device.cc	Tue Feb 20 23:26:59 2007 -0800
+++ b/src/node/serial-net-device.cc	Tue Feb 20 23:58:21 2007 -0800
@@ -27,6 +27,7 @@
 #include "queue.h"
 #include "serial-net-device.h"
 #include "serial-channel.h"
+#include "serial-phy.h"
 
 NS_DEBUG_COMPONENT_DEFINE ("SerialNetDevice");
 
@@ -46,6 +47,8 @@
   EnableMulticast();
   EnablePointToPoint();
   SetMtu(512); // bytes
+
+  m_phy = new SerialPhy(node, this);
 }
 
 SerialNetDevice::~SerialNetDevice()
--- a/src/node/serial-net-device.h	Tue Feb 20 23:26:59 2007 -0800
+++ b/src/node/serial-net-device.h	Tue Feb 20 23:58:21 2007 -0800
@@ -32,9 +32,11 @@
 namespace ns3 {
 
 class SerialChannel;
+class SerialPhy;
 class Queue;
 
 class SerialNetDevice : public NetDevice {
+friend class SerialPhy;
 public:
   SerialNetDevice(Node* node, const MacAddress& addr);
   virtual ~SerialNetDevice();
@@ -52,13 +54,16 @@
 
 protected:
   Queue* GetQueue(void) const { return m_queue;};
+  SerialChannel* GetChannel(void) const { return m_channel;};
 
 private:
   virtual void NotifyDataAvailable (void);
   virtual bool SendTo (Packet& p, const MacAddress& dest);
 
+  SerialPhy* m_phy;
   SerialChannel* m_channel;
   Queue* m_queue;
+
 };
 
 }; // namespace ns3
--- a/src/node/udp-socket.cc	Tue Feb 20 23:26:59 2007 -0800
+++ b/src/node/udp-socket.cc	Tue Feb 20 23:58:21 2007 -0800
@@ -164,4 +164,10 @@
   return m_node->GetUdp ();
 }
 
+Node *
+UdpSocket::GetNode (void) const
+{
+  return m_node;
+}
+
 }//namespace ns3
--- a/src/node/udp-socket.h	Tue Feb 20 23:26:59 2007 -0800
+++ b/src/node/udp-socket.h	Tue Feb 20 23:58:21 2007 -0800
@@ -114,6 +114,10 @@
    * to keep track of it.
    */
   void SetRxCallback (Callback<void,UdpSocket*,uint8_t const*,uint32_t,Ipv4Address,uint16_t> cb);
+  /** 
+   * Return pointer to node
+   */ 
+   Node* GetNode(void) const;
 
 private:
   friend class Udp;