diff --git a/samples/ns-2/simple.tcl.cc b/samples/ns-2/simple.tcl.cc index 49c417b0e..2cf2bd720 100644 --- a/samples/ns-2/simple.tcl.cc +++ b/samples/ns-2/simple.tcl.cc @@ -71,7 +71,7 @@ protected: 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 @@ GenerateTraffic (UdpSocket *socket, uint32_t size) 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 diff --git a/src/node/serial-net-device.cc b/src/node/serial-net-device.cc index ed7805d6b..41e775fd4 100644 --- a/src/node/serial-net-device.cc +++ b/src/node/serial-net-device.cc @@ -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 @@ SerialNetDevice::SerialNetDevice(Node* node, const MacAddress& addr) : EnableMulticast(); EnablePointToPoint(); SetMtu(512); // bytes + + m_phy = new SerialPhy(node, this); } SerialNetDevice::~SerialNetDevice() diff --git a/src/node/serial-net-device.h b/src/node/serial-net-device.h index d3dd40d0d..5d6f4078a 100644 --- a/src/node/serial-net-device.h +++ b/src/node/serial-net-device.h @@ -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 @@ public: 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 diff --git a/src/node/udp-socket.cc b/src/node/udp-socket.cc index 478cbcfae..306f3fbba 100644 --- a/src/node/udp-socket.cc +++ b/src/node/udp-socket.cc @@ -164,4 +164,10 @@ UdpSocket::GetUdp (void) const return m_node->GetUdp (); } +Node * +UdpSocket::GetNode (void) const +{ + return m_node; +} + }//namespace ns3 diff --git a/src/node/udp-socket.h b/src/node/udp-socket.h index 430c6c165..fcf3fde88 100644 --- a/src/node/udp-socket.h +++ b/src/node/udp-socket.h @@ -114,6 +114,10 @@ public: * to keep track of it. */ void SetRxCallback (Callback cb); + /** + * Return pointer to node + */ + Node* GetNode(void) const; private: friend class Udp;