diff --git a/samples/main-serial-net-device-if.cc b/samples/main-serial-net-device-if.cc index f91f07fbb..d3bc27e45 100644 --- a/samples/main-serial-net-device-if.cc +++ b/samples/main-serial-net-device-if.cc @@ -24,7 +24,6 @@ #include "ns3/debug.h" #include "ns3/internet-node.h" -#include "ns3/mac-address.h" #include "ns3/packet.h" #include "ns3/arp-ipv4-interface.h" #include "ns3/ipv4-address.h" @@ -136,21 +135,15 @@ int main (int argc, char *argv[]) // create two NetDevices and assign one to each node // Note: this would normally be done also in conjunction with // creating a Channel - // Here, we do not care about the Device Address (point-to-point) - // but more generally, we would use a subclass such as MacAddress - // as follows: MacAddress addra("00:00:00:00:00:01"); - // so we'll pretend and give them simple MacAddresses here - MacAddress addra("00:00:00:00:00:01"); - SerialNetDevice neta(&a, addra); + SerialNetDevice neta(&a); DropTailQueue dtqa; neta.AddQueue(&dtqa); neta.SetName("a.eth0"); - MacAddress addrb("00:00:00:00:00:02"); - SerialNetDevice netb(&b, addrb); + SerialNetDevice netb(&b); DropTailQueue dtqb; diff --git a/samples/ns-2/simple.cc b/samples/ns-2/simple.cc index fca489ca6..5c212a33f 100644 --- a/samples/ns-2/simple.cc +++ b/samples/ns-2/simple.cc @@ -34,7 +34,7 @@ // - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. // - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. // - DropTail queues -// - Tracing of queues and packet receptions to file out.tr +// - Tracing of queues and packet receptions to file "out.tr" #include #include @@ -97,23 +97,26 @@ public: void LogEnqueue (TraceContext const &context, const Packet &p) { + m_filestr << "+ " << Simulator::Now().GetSeconds() << " "; LogNodeInterface (context); - m_filestr << " que p=" << p.GetUid (); + m_filestr << "pkt-uid=" << p.GetUid () << " "; //PrintLlcPacket (p, m_filestr); m_filestr << std::endl; } void LogDequeue (TraceContext const &context, const Packet &p) { + m_filestr << "- " << Simulator::Now().GetSeconds() << " "; LogNodeInterface (context); - m_filestr << " deq p=" << p.GetUid (); + m_filestr << "pkt-uid=" << p.GetUid () << " "; //PrintLlcPacket (p, m_filestr); m_filestr << std::endl; } void LogDrop (TraceContext const &context, const Packet &p) { + m_filestr << "d " << Simulator::Now().GetSeconds() << " "; LogNodeInterface (context); - m_filestr << " dro p=" << p.GetUid (); + m_filestr << "pkt-uid=" << p.GetUid () << " "; //PrintLlcPacket (p, m_filestr); m_filestr << std::endl; } @@ -216,17 +219,14 @@ PrintRoutingTable (InternetNode *a, std::string name) static SerialChannel * AddDuplexLink( - std::string name, - uint64_t bps, - uint32_t delay, InternetNode* a, const Ipv4Address& addra, - const MacAddress& macaddra, InternetNode* b, const Ipv4Address& addrb, - const MacAddress& macaddrb) + uint64_t bps, + const Time& delay) { - SerialChannel* channel = new SerialChannel(name, bps, MilliSeconds(delay)); + SerialChannel* channel = new SerialChannel(bps, delay); // Duplex link is assumed to be subnetted as a /30 // May run this unnumbered in the future? @@ -235,7 +235,7 @@ AddDuplexLink( DropTailQueue* dtqa = new DropTailQueue(); - SerialNetDevice* neta = new SerialNetDevice(a, macaddra); + SerialNetDevice* neta = new SerialNetDevice(a); neta->AddQueue(dtqa); Ipv4Interface *interfA = new ArpIpv4Interface (a, neta); uint32_t indexA = a->GetIpv4 ()->AddInterface (interfA); @@ -247,7 +247,7 @@ AddDuplexLink( DropTailQueue* dtqb = new DropTailQueue(); - SerialNetDevice* netb = new SerialNetDevice(b, macaddrb); + SerialNetDevice* netb = new SerialNetDevice(b); netb->AddQueue(dtqb); Ipv4Interface *interfB = new ArpIpv4Interface (b, netb); uint32_t indexB = b->GetIpv4 ()->AddInterface (interfB); @@ -272,7 +272,6 @@ AddDuplexLink( int main (int argc, char *argv[]) { - #if 0 DebugComponentEnable("Queue"); DebugComponentEnable("DropTailQueue"); @@ -299,17 +298,14 @@ int main (int argc, char *argv[]) n2->SetName(std::string("Node 2")); n3->SetName(std::string("Node 3")); - SerialChannel* ch1 = AddDuplexLink ("Channel 1", 5000000, 2, - n0, Ipv4Address("10.1.1.1"), MacAddress("00:00:00:00:00:01"), - n2, Ipv4Address("10.1.1.2"), MacAddress("00:00:00:00:00:02")); + SerialChannel* ch1 = AddDuplexLink (n0, Ipv4Address("10.1.1.1"), + n2, Ipv4Address("10.1.1.2"), 5000000, MilliSeconds(2)); - SerialChannel* ch2 = AddDuplexLink ("Channel 2", 5000000, 2, - n1, Ipv4Address("10.1.2.1"), MacAddress("00:00:00:00:00:03"), - n2, Ipv4Address("10.1.2.2"), MacAddress("00:00:00:00:00:04")); + SerialChannel* ch2 = AddDuplexLink (n1, Ipv4Address("10.1.2.1"), + n2, Ipv4Address("10.1.2.2"), 5000000, MilliSeconds(2)); - SerialChannel* ch3 = AddDuplexLink ("Channel 3", 1500000, 10, - n2, Ipv4Address("10.1.3.1"), MacAddress("00:00:00:00:00:05"), - n3, Ipv4Address("10.1.3.2"), MacAddress("00:00:00:00:00:06")); + SerialChannel* ch3 = AddDuplexLink (n2, Ipv4Address("10.1.3.1"), + n3, Ipv4Address("10.1.3.2"), 1500000, MilliSeconds(10)); DatagramSocket *source0 = new DatagramSocket (n0); DatagramSocket *source3 = new DatagramSocket (n3); @@ -325,13 +321,17 @@ int main (int argc, char *argv[]) n0->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); n3->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); - Tracer tracer("serial-net-test.log"); + Tracer tracer("out.tr"); TraceRoot::Connect ("/nodes/*/ipv4/interfaces/*/netdevice/queue/enqueue", MakeCallback (&Tracer::LogEnqueue, &tracer)); TraceRoot::Connect ("/nodes/*/ipv4/interfaces/*/netdevice/queue/dequeue", MakeCallback (&Tracer::LogDequeue, &tracer)); TraceRoot::Connect ("/nodes/*/ipv4/interfaces/*/netdevice/queue/drop", MakeCallback (&Tracer::LogDrop, &tracer)); +#if 0 + TraceRoot::Connect ("/nodes/*/ipv4/interfaces/*/netdevice/queue/receive", + MakeCallback (&Tracer::LogReceive, &tracer)); +#endif PrintTraffic (sink3); diff --git a/src/devices/serial/serial-channel.cc b/src/devices/serial/serial-channel.cc index bbcd75366..ece101dbd 100644 --- a/src/devices/serial/serial-channel.cc +++ b/src/devices/serial/serial-channel.cc @@ -46,11 +46,24 @@ SerialChannel::SerialChannel() } SerialChannel::SerialChannel( - std::string name, DataRate bps, Time delay) : - Channel (name), + Channel ("Serial Channel"), + m_bps (bps), + m_delay (delay), + m_nDevices(0) +{ + NS_DEBUG("SerialChannel::SerialChannel (" << Channel::GetName() << ", " << bps << ", " << + delay << ")"); +} + +SerialChannel::SerialChannel( + std::string name, + DataRate bps, + Time delay) +: + Channel (name), m_bps (bps), m_delay (delay), m_nDevices(0) diff --git a/src/devices/serial/serial-channel.h b/src/devices/serial/serial-channel.h index 76d19b0f1..a4400ed7f 100644 --- a/src/devices/serial/serial-channel.h +++ b/src/devices/serial/serial-channel.h @@ -59,6 +59,7 @@ public: static const int N_DEVICES = 2; SerialChannel (); + SerialChannel (DataRate bps, Time delay); SerialChannel (std::string name, DataRate bps, Time delay); void Attach (SerialPhy* phy); @@ -71,7 +72,6 @@ public: private: void TransmitCompleteEvent (Packet p, SerialPhy *src); - std::string m_name; DataRate m_bps; Time m_delay; diff --git a/src/devices/serial/serial-net-device.cc b/src/devices/serial/serial-net-device.cc index f62303873..3f8d6d048 100644 --- a/src/devices/serial/serial-net-device.cc +++ b/src/devices/serial/serial-net-device.cc @@ -33,10 +33,10 @@ NS_DEBUG_COMPONENT_DEFINE ("SerialNetDevice"); namespace ns3 { -SerialNetDevice::SerialNetDevice(Node* node, const MacAddress& addr) : - NetDevice(node, addr) +SerialNetDevice::SerialNetDevice(Node* node) : + NetDevice(node, MacAddress("00:00:00:00:00:00")) { - NS_DEBUG ("SerialNetDevice::SerialNetDevice (" << node << ", " << &addr << ")"); + NS_DEBUG ("SerialNetDevice::SerialNetDevice (" << node << ")"); // BUGBUG FIXME // diff --git a/src/devices/serial/serial-net-device.h b/src/devices/serial/serial-net-device.h index 91b3c8cca..69c6a7c4c 100644 --- a/src/devices/serial/serial-net-device.h +++ b/src/devices/serial/serial-net-device.h @@ -39,7 +39,7 @@ public: enum TraceType { QUEUE, }; - SerialNetDevice(Node* node, const MacAddress& addr); + SerialNetDevice(Node* node); virtual ~SerialNetDevice(); private: