A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
15
class
PointToPointTest
:
public
TestCase
16
{
17
public
:
21
PointToPointTest
();
22
26
virtual
void
DoRun (
void
);
27
28
private
:
34
void
SendOnePacket
(
Ptr<PointToPointNetDevice>
device);
35
};
36
37
PointToPointTest::PointToPointTest
()
38
:
TestCase
(
"PointToPoint"
)
39
{
40
}
41
42
void
43
PointToPointTest::SendOnePacket
(
Ptr<PointToPointNetDevice>
device)
44
{
45
Ptr<Packet>
p = Create<Packet> ();
46
device->
Send
(p, device->
GetBroadcast
(), 0x800);
47
}
48
49
50
void
51
PointToPointTest::DoRun
(
void
)
52
{
53
Ptr<Node>
a = CreateObject<Node> ();
54
Ptr<Node>
b = CreateObject<Node> ();
55
Ptr<PointToPointNetDevice>
devA = CreateObject<PointToPointNetDevice> ();
56
Ptr<PointToPointNetDevice>
devB = CreateObject<PointToPointNetDevice> ();
57
Ptr<PointToPointChannel>
channel = CreateObject<PointToPointChannel> ();
58
59
devA->Attach (channel);
60
devA->SetAddress (Mac48Address::Allocate ());
61
devA->SetQueue (CreateObject<DropTailQueue> ());
62
devB->Attach (channel);
63
devB->SetAddress (Mac48Address::Allocate ());
64
devB->SetQueue (CreateObject<DropTailQueue> ());
65
66
a->
AddDevice
(devA);
67
b->AddDevice (devB);
68
69
Simulator::Schedule (
Seconds
(1.0), &
PointToPointTest::SendOnePacket
,
this
, devA);
70
71
Simulator::Run ();
72
73
Simulator::Destroy ();
74
}
75
79
class
PointToPointTestSuite
:
public
TestSuite
80
{
81
public
:
85
PointToPointTestSuite
();
86
};
87
88
PointToPointTestSuite::PointToPointTestSuite
()
89
:
TestSuite
(
"devices-point-to-point"
, UNIT)
90
{
91
AddTestCase
(
new
PointToPointTest
, TestCase::QUICK);
92
}
93
94
static
PointToPointTestSuite
g_pointToPointTestSuite
;
PointToPointTest::DoRun
virtual void DoRun(void)
Run the test.
Definition:
point-to-point-test.cc:51
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
PointToPointTest
Test class for PointToPoint model.
Definition:
point-to-point-test.cc:15
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1276
ns3::TestCase
encapsulates test code
Definition:
test.h:1108
PointToPointTest::SendOnePacket
void SendOnePacket(Ptr< PointToPointNetDevice > device)
Send one packet to the device specified.
Definition:
point-to-point-test.cc:43
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition:
test.cc:190
g_pointToPointTestSuite
static PointToPointTestSuite g_pointToPointTestSuite
The testsuite.
Definition:
point-to-point-test.cc:94
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SendOnePacket
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
Definition:
lr-wpan-phy-test.cc:47
PointToPointTestSuite
TestSuite for PointToPoint module.
Definition:
point-to-point-test.cc:79
ns3::PointToPointNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition:
point-to-point-net-device.cc:508
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition:
node.cc:121
PointToPointTestSuite::PointToPointTestSuite
PointToPointTestSuite()
Constructor.
Definition:
point-to-point-test.cc:88
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:866
PointToPointTest::PointToPointTest
PointToPointTest()
Create the test.
Definition:
point-to-point-test.cc:37
ns3::PointToPointNetDevice::GetBroadcast
virtual Address GetBroadcast(void) const
Definition:
point-to-point-net-device.cc:466
src
point-to-point
test
point-to-point-test.cc
Generated on Wed May 13 2015 14:59:29 for ns-3 by
1.8.9.1