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
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
);
69
}
70
71
static
PointToPointTestSuite
g_pointToPointTestSuite
;
72
73
}
// namespace ns3
src
point-to-point
test
point-to-point-test.cc
Generated on Tue Oct 9 2012 16:45:45 for ns-3 by
1.8.1.2