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
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
:
12
PointToPointTest
();
13
14
virtual
void
DoRun (
void
);
15
16
private
:
17
void
SendOnePacket (
Ptr<PointToPointNetDevice>
device);
18
};
19
20
PointToPointTest::PointToPointTest
()
21
:
TestCase
(
"PointToPoint"
)
22
{
23
}
24
25
void
26
PointToPointTest::SendOnePacket
(
Ptr<PointToPointNetDevice>
device)
27
{
28
Ptr<Packet>
p = Create<Packet> ();
29
device->
Send
(p, device->
GetBroadcast
(), 0x800);
30
}
31
32
33
void
34
PointToPointTest::DoRun
(
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
//-----------------------------------------------------------------------------
59
class
PointToPointTestSuite
:
public
TestSuite
60
{
61
public
:
62
PointToPointTestSuite
();
63
};
64
65
PointToPointTestSuite::PointToPointTestSuite
()
66
:
TestSuite
(
"devices-point-to-point"
, UNIT)
67
{
68
AddTestCase
(
new
PointToPointTest
, TestCase::QUICK);
69
}
70
71
static
PointToPointTestSuite
g_pointToPointTestSuite
;
PointToPointTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
point-to-point-test.cc:34
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
PointToPointTest
Definition:
point-to-point-test.cc:9
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
ns3::TestCase
encapsulates test code
Definition:
test.h:849
PointToPointTest::SendOnePacket
void SendOnePacket(Ptr< PointToPointNetDevice > device)
Definition:
point-to-point-test.cc:26
g_pointToPointTestSuite
static PointToPointTestSuite g_pointToPointTestSuite
Definition:
point-to-point-test.cc:71
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:173
PointToPointTestSuite
Definition:
point-to-point-test.cc:59
ns3::PointToPointNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition:
point-to-point-net-device.cc:463
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Definition:
node.cc:118
PointToPointTestSuite::PointToPointTestSuite
PointToPointTestSuite()
Definition:
point-to-point-test.cc:65
PointToPointTest::PointToPointTest
PointToPointTest()
Definition:
point-to-point-test.cc:20
ns3::PointToPointNetDevice::GetBroadcast
virtual Address GetBroadcast(void) const
Definition:
point-to-point-net-device.cc:426
src
point-to-point
test
point-to-point-test.cc
Generated on Sat Apr 19 2014 14:07:07 for ns-3 by
1.8.6