A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
point-to-point-test.cc
Go to the documentation of this file.
1 #include "ns3/test.h"
2 #include "ns3/drop-tail-queue.h"
3 #include "ns3/simulator.h"
4 #include "ns3/point-to-point-net-device.h"
5 #include "ns3/point-to-point-channel.h"
6 
7 using namespace ns3;
8 
9 class PointToPointTest : public TestCase
10 {
11 public:
13 
14  virtual void DoRun (void);
15 
16 private:
17  void SendOnePacket (Ptr<PointToPointNetDevice> device);
18 };
19 
21  : TestCase ("PointToPoint")
22 {
23 }
24 
25 void
27 {
28  Ptr<Packet> p = Create<Packet> ();
29  device->Send (p, device->GetBroadcast (), 0x800);
30 }
31 
32 
33 void
35 {
36  Ptr<Node> a = CreateObject<Node> ();
37  Ptr<Node> b = CreateObject<Node> ();
38  Ptr<PointToPointNetDevice> devA = CreateObject<PointToPointNetDevice> ();
39  Ptr<PointToPointNetDevice> devB = CreateObject<PointToPointNetDevice> ();
40  Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> ();
41 
42  devA->Attach (channel);
43  devA->SetAddress (Mac48Address::Allocate ());
44  devA->SetQueue (CreateObject<DropTailQueue> ());
45  devB->Attach (channel);
46  devB->SetAddress (Mac48Address::Allocate ());
47  devB->SetQueue (CreateObject<DropTailQueue> ());
48 
49  a->AddDevice (devA);
50  b->AddDevice (devB);
51 
52  Simulator::Schedule (Seconds (1.0), &PointToPointTest::SendOnePacket, this, devA);
53 
54  Simulator::Run ();
55 
56  Simulator::Destroy ();
57 }
58 //-----------------------------------------------------------------------------
60 {
61 public:
63 };
64 
66  : TestSuite ("devices-point-to-point", UNIT)
67 {
69 }
70