00001 #ifdef RUN_SELF_TESTS 00002 00003 #include "ns3/test.h" 00004 #include "ns3/drop-tail-queue.h" 00005 #include "ns3/simulator.h" 00006 #include "point-to-point-net-device.h" 00007 #include "point-to-point-channel.h" 00008 00009 namespace ns3 { 00010 00011 class PointToPointTest : public Test 00012 { 00013 public: 00014 PointToPointTest (); 00015 00016 virtual bool RunTests (void); 00017 00018 private: 00019 void SendOnePacket (Ptr<PointToPointNetDevice> device); 00020 }; 00021 00022 PointToPointTest::PointToPointTest () 00023 : Test ("PointToPoint") 00024 {} 00025 00026 void 00027 PointToPointTest::SendOnePacket (Ptr<PointToPointNetDevice> device) 00028 { 00029 Ptr<Packet> p = Create<Packet> (); 00030 device->Send (p, device->GetBroadcast (), 0x800); 00031 } 00032 00033 00034 bool 00035 PointToPointTest::RunTests (void) 00036 { 00037 bool result = true; 00038 00039 Ptr<Node> a = CreateObject<Node> (); 00040 Ptr<Node> b = CreateObject<Node> (); 00041 Ptr<PointToPointNetDevice> devA = CreateObject<PointToPointNetDevice> (); 00042 Ptr<PointToPointNetDevice> devB = CreateObject<PointToPointNetDevice> (); 00043 Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> (); 00044 00045 devA->Attach (channel); 00046 devA->SetAddress (Mac48Address::Allocate ()); 00047 devA->SetQueue (CreateObject<DropTailQueue> ()); 00048 devB->Attach (channel); 00049 devB->SetAddress (Mac48Address::Allocate ()); 00050 devB->SetQueue (CreateObject<DropTailQueue> ()); 00051 00052 a->AddDevice (devA); 00053 b->AddDevice (devB); 00054 00055 Simulator::Schedule (Seconds (1.0), &PointToPointTest::SendOnePacket, this, devA); 00056 00057 Simulator::Run (); 00058 00059 Simulator::Destroy (); 00060 00061 return result; 00062 } 00063 00064 static PointToPointTest g_pointToPointTest; 00065 00066 } // namespace ns3 00067 00068 #endif /* RUN_SELF_TESTS */