This documentation is not the
Latest Release
.
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "ns3/test.h"
22
#include "ns3/drop-tail-queue.h"
23
#include "ns3/simulator.h"
24
#include "ns3/point-to-point-net-device.h"
25
#include "ns3/point-to-point-channel.h"
26
27
using namespace
ns3
;
28
35
class
PointToPointTest
:
public
TestCase
36
{
37
public
:
41
PointToPointTest
();
42
46
virtual
void
DoRun (
void
);
47
48
private
:
54
void
SendOnePacket
(
Ptr<PointToPointNetDevice>
device);
55
};
56
57
PointToPointTest::PointToPointTest
()
58
:
TestCase
(
"PointToPoint"
)
59
{
60
}
61
62
void
63
PointToPointTest::SendOnePacket
(
Ptr<PointToPointNetDevice>
device)
64
{
65
Ptr<Packet>
p = Create<Packet> ();
66
device->
Send
(p, device->
GetBroadcast
(), 0x800);
67
}
68
69
70
void
71
PointToPointTest::DoRun
(
void
)
72
{
73
Ptr<Node>
a = CreateObject<Node> ();
74
Ptr<Node>
b = CreateObject<Node> ();
75
Ptr<PointToPointNetDevice>
devA = CreateObject<PointToPointNetDevice> ();
76
Ptr<PointToPointNetDevice>
devB = CreateObject<PointToPointNetDevice> ();
77
Ptr<PointToPointChannel>
channel
= CreateObject<PointToPointChannel> ();
78
79
devA->Attach (channel);
80
devA->SetAddress (Mac48Address::Allocate ());
81
devA->SetQueue (CreateObject<DropTailQueue> ());
82
devB->Attach (channel);
83
devB->SetAddress (Mac48Address::Allocate ());
84
devB->SetQueue (CreateObject<DropTailQueue> ());
85
86
a->
AddDevice
(devA);
87
b->AddDevice (devB);
88
89
Simulator::Schedule (
Seconds
(1.0), &
PointToPointTest::SendOnePacket
,
this
, devA);
90
91
Simulator::Run ();
92
93
Simulator::Destroy ();
94
}
95
99
class
PointToPointTestSuite
:
public
TestSuite
100
{
101
public
:
105
PointToPointTestSuite
();
106
};
107
108
PointToPointTestSuite::PointToPointTestSuite
()
109
:
TestSuite
(
"devices-point-to-point"
, UNIT)
110
{
111
AddTestCase
(
new
PointToPointTest
, TestCase::QUICK);
112
}
113
114
static
PointToPointTestSuite
g_pointToPointTestSuite
;
third.channel
tuple channel
Definition:
third.py:85
PointToPointTest::DoRun
virtual void DoRun(void)
Run the test.
Definition:
point-to-point-test.cc:71
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:35
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1333
ns3::TestCase
encapsulates test code
Definition:
test.h:1147
PointToPointTest::SendOnePacket
void SendOnePacket(Ptr< PointToPointNetDevice > device)
Send one packet to the device specified.
Definition:
point-to-point-test.cc:63
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition:
test.cc:297
g_pointToPointTestSuite
static PointToPointTestSuite g_pointToPointTestSuite
The testsuite.
Definition:
point-to-point-test.cc:114
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:99
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:128
PointToPointTestSuite::PointToPointTestSuite
PointToPointTestSuite()
Constructor.
Definition:
point-to-point-test.cc:108
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:895
PointToPointTest::PointToPointTest
PointToPointTest()
Create the test.
Definition:
point-to-point-test.cc:57
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 Nov 11 2015 20:00:46 for ns-3 by
1.8.9.1