A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
mesh-information-element-vector-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Pavel Boyko <boyko@iitp.ru>
7
*/
8
9
#include "ns3/mesh-information-element-vector.h"
10
#include "ns3/test.h"
11
// All information elements:
12
#include "ns3/ie-dot11s-beacon-timing.h"
13
#include "ns3/ie-dot11s-configuration.h"
14
#include "ns3/ie-dot11s-id.h"
15
#include "ns3/ie-dot11s-metric-report.h"
16
#include "ns3/ie-dot11s-peer-management.h"
17
#include "ns3/ie-dot11s-peering-protocol.h"
18
#include "ns3/ie-dot11s-perr.h"
19
#include "ns3/ie-dot11s-prep.h"
20
#include "ns3/ie-dot11s-preq.h"
21
#include "ns3/ie-dot11s-rann.h"
22
23
using namespace
ns3
;
24
25
/**
26
* \ingroup mesh
27
* \ingroup tests
28
* \defgroup mesh-test mesh module tests
29
*/
30
31
/**
32
* \ingroup mesh-test
33
*
34
* \brief Built-in self test for MeshInformationElementVector and all IE
35
*/
36
struct
MeshInformationElementVectorBist
:
public
TestCase
37
{
38
MeshInformationElementVectorBist
()
39
:
TestCase
(
"Serialization test for all mesh information elements"
){};
40
void
DoRun
()
override
;
41
};
42
43
void
44
MeshInformationElementVectorBist::DoRun
()
45
{
46
MeshInformationElementVector
vector;
47
{
48
// Mesh ID test
49
Ptr<dot11s::IeMeshId>
meshId =
Create<dot11s::IeMeshId>
(
"qwerty"
);
50
vector.
AddInformationElement
(meshId);
51
}
52
{
53
Ptr<dot11s::IeConfiguration>
config =
Create<dot11s::IeConfiguration>
();
54
vector.
AddInformationElement
(config);
55
}
56
{
57
Ptr<dot11s::IeLinkMetricReport>
report =
Create<dot11s::IeLinkMetricReport>
(123456);
58
vector.
AddInformationElement
(report);
59
}
60
{
61
Ptr<dot11s::IePeerManagement>
peerMan1 =
Create<dot11s::IePeerManagement>
();
62
peerMan1->SetPeerOpen(1);
63
Ptr<dot11s::IePeerManagement>
peerMan2 =
Create<dot11s::IePeerManagement>
();
64
peerMan2->SetPeerConfirm(1, 2);
65
Ptr<dot11s::IePeerManagement>
peerMan3 =
Create<dot11s::IePeerManagement>
();
66
peerMan3->SetPeerClose(1, 2,
dot11s::REASON11S_MESH_CAPABILITY_POLICY_VIOLATION
);
67
vector.
AddInformationElement
(peerMan1);
68
vector.
AddInformationElement
(peerMan2);
69
vector.
AddInformationElement
(peerMan3);
70
}
71
{
72
Ptr<dot11s::IeBeaconTiming>
beaconTiming =
Create<dot11s::IeBeaconTiming>
();
73
beaconTiming->AddNeighboursTimingElementUnit(1,
Seconds
(1.0),
Seconds
(4.0));
74
beaconTiming->AddNeighboursTimingElementUnit(2,
Seconds
(2.0),
Seconds
(3.0));
75
beaconTiming->AddNeighboursTimingElementUnit(3,
Seconds
(3.0),
Seconds
(2.0));
76
beaconTiming->AddNeighboursTimingElementUnit(4,
Seconds
(4.0),
Seconds
(1.0));
77
vector.
AddInformationElement
(beaconTiming);
78
}
79
{
80
Ptr<dot11s::IeRann>
rann =
Create<dot11s::IeRann>
();
81
rann->SetFlags(1);
82
rann->SetHopcount(2);
83
rann->SetTTL(4);
84
rann->DecrementTtl();
85
NS_TEST_ASSERT_MSG_EQ
(rann->GetTtl(), 3,
"SetTtl works"
);
86
rann->SetOriginatorAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
87
rann->SetDestSeqNumber(5);
88
rann->SetMetric(6);
89
rann->IncrementMetric(2);
90
NS_TEST_ASSERT_MSG_EQ
(rann->GetMetric(), 8,
"SetMetric works"
);
91
vector.
AddInformationElement
(rann);
92
}
93
{
94
Ptr<dot11s::IePreq>
preq =
Create<dot11s::IePreq>
();
95
preq->SetHopcount(0);
96
preq->SetTTL(1);
97
preq->SetPreqID(2);
98
preq->SetOriginatorAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
99
preq->SetOriginatorSeqNumber(3);
100
preq->SetLifetime(4);
101
preq->AddDestinationAddressElement(
false
,
false
,
Mac48Address
(
"11:11:11:11:11:11"
), 5);
102
preq->AddDestinationAddressElement(
false
,
false
,
Mac48Address
(
"22:22:22:22:22:22"
), 6);
103
vector.
AddInformationElement
(preq);
104
}
105
{
106
Ptr<dot11s::IePrep>
prep =
Create<dot11s::IePrep>
();
107
prep->SetFlags(12);
108
prep->SetHopcount(11);
109
prep->SetTtl(10);
110
prep->SetDestinationAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
111
prep->SetDestinationSeqNumber(123);
112
prep->SetLifetime(5000);
113
prep->SetMetric(4321);
114
prep->SetOriginatorAddress(
Mac48Address
(
"33:00:22:00:11:00"
));
115
prep->SetOriginatorSeqNumber(666);
116
vector.
AddInformationElement
(prep);
117
}
118
{
119
Ptr<dot11s::IePerr>
perr =
Create<dot11s::IePerr>
();
120
dot11s::HwmpProtocol::FailedDestination
dest;
121
dest.
destination
=
Mac48Address
(
"11:22:33:44:55:66"
);
122
dest.
seqnum
= 1;
123
perr->AddAddressUnit(dest);
124
dest.
destination
=
Mac48Address
(
"10:20:30:40:50:60"
);
125
dest.
seqnum
= 2;
126
perr->AddAddressUnit(dest);
127
dest.
destination
=
Mac48Address
(
"01:02:03:04:05:06"
);
128
dest.
seqnum
= 3;
129
perr->AddAddressUnit(dest);
130
vector.
AddInformationElement
(perr);
131
}
132
Ptr<Packet>
packet =
Create<Packet>
();
133
packet->AddHeader(vector);
134
uint32_t
size = vector.
GetSerializedSize
();
135
MeshInformationElementVector
resultVector;
136
packet->RemoveHeader(resultVector, size);
137
NS_TEST_ASSERT_MSG_EQ
(vector,
138
resultVector,
139
"Roundtrip serialization of all known information elements works"
);
140
}
141
142
/**
143
* \ingroup mesh-test
144
*
145
* \brief Mesh Test Suite
146
*/
147
class
MeshTestSuite
:
public
TestSuite
148
{
149
public
:
150
MeshTestSuite
();
151
};
152
153
MeshTestSuite::MeshTestSuite
()
154
:
TestSuite
(
"devices-mesh"
,
Type
::UNIT)
155
{
156
AddTestCase
(
new
MeshInformationElementVectorBist
, TestCase::Duration::QUICK);
157
}
158
159
static
MeshTestSuite
g_meshTestSuite
;
///< the test suite
MeshTestSuite
Mesh Test Suite.
Definition
mesh-information-element-vector-test-suite.cc:148
MeshTestSuite::MeshTestSuite
MeshTestSuite()
Definition
mesh-information-element-vector-test-suite.cc:153
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::MeshInformationElementVector
Information element vector.
Definition
mesh-information-element-vector.h:33
ns3::MeshInformationElementVector::AddInformationElement
bool AddInformationElement(Ptr< WifiInformationElement > element)
add an IE, if maxSize has exceeded, returns false
Definition
mesh-information-element-vector.cc:177
ns3::MeshInformationElementVector::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
mesh-information-element-vector.cc:63
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
uint32_t
ns3::dot11s::REASON11S_MESH_CAPABILITY_POLICY_VIOLATION
@ REASON11S_MESH_CAPABILITY_POLICY_VIOLATION
Definition
ie-dot11s-peer-management.h:28
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition
test.h:134
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
g_meshTestSuite
static MeshTestSuite g_meshTestSuite
the test suite
Definition
mesh-information-element-vector-test-suite.cc:159
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
MeshInformationElementVectorBist
Built-in self test for MeshInformationElementVector and all IE.
Definition
mesh-information-element-vector-test-suite.cc:37
MeshInformationElementVectorBist::MeshInformationElementVectorBist
MeshInformationElementVectorBist()
Definition
mesh-information-element-vector-test-suite.cc:38
MeshInformationElementVectorBist::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
mesh-information-element-vector-test-suite.cc:44
ns3::dot11s::HwmpProtocol::FailedDestination
structure of unreachable destination - address and sequence number
Definition
hwmp-protocol.h:78
ns3::dot11s::HwmpProtocol::FailedDestination::destination
Mac48Address destination
destination address
Definition
hwmp-protocol.h:79
ns3::dot11s::HwmpProtocol::FailedDestination::seqnum
uint32_t seqnum
sequence number
Definition
hwmp-protocol.h:80
src
mesh
test
mesh-information-element-vector-test-suite.cc
Generated on Fri Nov 8 2024 13:59:04 for ns-3 by
1.11.0