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
hello-regression-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 IITP RAS
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
* Authors: Pavel Boyko <boyko@iitp.ru>
19
*/
20
21
#include "
hello-regression-test.h
"
22
#include "ns3/simulator.h"
23
#include "ns3/random-variable-stream.h"
24
#include "ns3/rng-seed-manager.h"
25
#include "ns3/double.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/string.h"
28
#include "ns3/pcap-file.h"
29
#include "ns3/olsr-helper.h"
30
#include "ns3/internet-stack-helper.h"
31
#include "ns3/point-to-point-helper.h"
32
#include "ns3/ipv4-address-helper.h"
33
#include "ns3/abort.h"
34
#include "ns3/pcap-test.h"
35
36
namespace
ns3
37
{
38
namespace
olsr
39
{
40
41
const
char
*
const
HelloRegressionTest::PREFIX
=
"olsr-hello-regression-test"
;
42
43
HelloRegressionTest::HelloRegressionTest
() :
44
TestCase
(
"Test OLSR Hello messages generation"
),
45
m_time (
Seconds
(5))
46
{
47
}
48
49
HelloRegressionTest::~HelloRegressionTest
()
50
{
51
}
52
53
void
54
HelloRegressionTest::DoRun
()
55
{
56
RngSeedManager::SetSeed
(12345);
57
RngSeedManager::SetRun
(7);
58
CreateNodes
();
59
60
Simulator::Stop
(
m_time
);
61
Simulator::Run
();
62
Simulator::Destroy
();
63
64
CheckResults
();
65
}
66
67
void
68
HelloRegressionTest::CreateNodes
()
69
{
70
// create 2 nodes
71
NodeContainer
c;
72
c.
Create
(2);
73
// install TCP/IP & OLSR
74
OlsrHelper
olsr;
75
InternetStackHelper
internet;
76
internet.
SetRoutingHelper
(olsr);
77
internet.
Install
(c);
78
// Assign OLSR RVs to specific streams
79
int64_t streamsUsed = olsr.
AssignStreams
(c, 0);
80
NS_TEST_ASSERT_MSG_EQ
(streamsUsed, 2,
"Should have assigned 2 streams"
);
81
// create p2p channel & devices
82
PointToPointHelper
p2p;
83
p2p.
SetDeviceAttribute
(
"DataRate"
,
StringValue
(
"5Mbps"
));
84
p2p.
SetChannelAttribute
(
"Delay"
,
StringValue
(
"2ms"
));
85
NetDeviceContainer
nd = p2p.
Install
(c);
86
// setup IP addresses
87
Ipv4AddressHelper
ipv4;
88
ipv4.
SetBase
(
"10.1.1.0"
,
"255.255.255.0"
);
89
ipv4.
Assign
(nd);
90
// setup PCAP traces
91
p2p.
EnablePcapAll
(
CreateTempDirFilename
(
PREFIX
));
92
}
93
94
void
95
HelloRegressionTest::CheckResults
()
96
{
97
for
(uint32_t i = 0; i < 2; ++i)
98
{
99
NS_PCAP_TEST_EXPECT_EQ
(
PREFIX
<<
"-"
<< i <<
"-1.pcap"
);
100
}
101
}
102
103
}
104
}
src
olsr
test
hello-regression-test.cc
Generated on Tue Nov 13 2012 10:32:21 for ns-3 by
1.8.1.2