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
{
41
}
42
43
void
DoRun
()
override
;
44
};
45
46
void
47
MeshInformationElementVectorBist::DoRun
()
48
{
49
MeshInformationElementVector
vector;
50
{
51
// Mesh ID test
52
Ptr<dot11s::IeMeshId>
meshId =
Create<dot11s::IeMeshId>
(
"qwerty"
);
53
vector.
AddInformationElement
(meshId);
54
}
55
{
56
Ptr<dot11s::IeConfiguration>
config =
Create<dot11s::IeConfiguration>
();
57
vector.
AddInformationElement
(config);
58
}
59
{
60
Ptr<dot11s::IeLinkMetricReport>
report =
Create<dot11s::IeLinkMetricReport>
(123456);
61
vector.
AddInformationElement
(report);
62
}
63
{
64
Ptr<dot11s::IePeerManagement>
peerMan1 =
Create<dot11s::IePeerManagement>
();
65
peerMan1->SetPeerOpen(1);
66
Ptr<dot11s::IePeerManagement>
peerMan2 =
Create<dot11s::IePeerManagement>
();
67
peerMan2->SetPeerConfirm(1, 2);
68
Ptr<dot11s::IePeerManagement>
peerMan3 =
Create<dot11s::IePeerManagement>
();
69
peerMan3->SetPeerClose(1, 2,
dot11s::REASON11S_MESH_CAPABILITY_POLICY_VIOLATION
);
70
vector.
AddInformationElement
(peerMan1);
71
vector.
AddInformationElement
(peerMan2);
72
vector.
AddInformationElement
(peerMan3);
73
}
74
{
75
Ptr<dot11s::IeBeaconTiming>
beaconTiming =
Create<dot11s::IeBeaconTiming>
();
76
beaconTiming->AddNeighboursTimingElementUnit(1,
Seconds
(1),
Seconds
(4));
77
beaconTiming->AddNeighboursTimingElementUnit(2,
Seconds
(2),
Seconds
(3));
78
beaconTiming->AddNeighboursTimingElementUnit(3,
Seconds
(3),
Seconds
(2));
79
beaconTiming->AddNeighboursTimingElementUnit(4,
Seconds
(4),
Seconds
(1));
80
vector.
AddInformationElement
(beaconTiming);
81
}
82
{
83
Ptr<dot11s::IeRann>
rann =
Create<dot11s::IeRann>
();
84
rann->SetFlags(1);
85
rann->SetHopcount(2);
86
rann->SetTTL(4);
87
rann->DecrementTtl();
88
NS_TEST_ASSERT_MSG_EQ
(rann->GetTtl(), 3,
"SetTtl works"
);
89
rann->SetOriginatorAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
90
rann->SetDestSeqNumber(5);
91
rann->SetMetric(6);
92
rann->IncrementMetric(2);
93
NS_TEST_ASSERT_MSG_EQ
(rann->GetMetric(), 8,
"SetMetric works"
);
94
vector.
AddInformationElement
(rann);
95
}
96
{
97
Ptr<dot11s::IePreq>
preq =
Create<dot11s::IePreq>
();
98
preq->SetHopcount(0);
99
preq->SetTTL(1);
100
preq->SetPreqID(2);
101
preq->SetOriginatorAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
102
preq->SetOriginatorSeqNumber(3);
103
preq->SetLifetime(4);
104
preq->AddDestinationAddressElement(
false
,
false
,
Mac48Address
(
"11:11:11:11:11:11"
), 5);
105
preq->AddDestinationAddressElement(
false
,
false
,
Mac48Address
(
"22:22:22:22:22:22"
), 6);
106
vector.
AddInformationElement
(preq);
107
}
108
{
109
Ptr<dot11s::IePrep>
prep =
Create<dot11s::IePrep>
();
110
prep->SetFlags(12);
111
prep->SetHopcount(11);
112
prep->SetTtl(10);
113
prep->SetDestinationAddress(
Mac48Address
(
"11:22:33:44:55:66"
));
114
prep->SetDestinationSeqNumber(123);
115
prep->SetLifetime(5000);
116
prep->SetMetric(4321);
117
prep->SetOriginatorAddress(
Mac48Address
(
"33:00:22:00:11:00"
));
118
prep->SetOriginatorSeqNumber(666);
119
vector.
AddInformationElement
(prep);
120
}
121
{
122
Ptr<dot11s::IePerr>
perr =
Create<dot11s::IePerr>
();
123
dot11s::HwmpProtocol::FailedDestination
dest;
124
dest.
destination
=
Mac48Address
(
"11:22:33:44:55:66"
);
125
dest.
seqnum
= 1;
126
perr->AddAddressUnit(dest);
127
dest.
destination
=
Mac48Address
(
"10:20:30:40:50:60"
);
128
dest.
seqnum
= 2;
129
perr->AddAddressUnit(dest);
130
dest.
destination
=
Mac48Address
(
"01:02:03:04:05:06"
);
131
dest.
seqnum
= 3;
132
perr->AddAddressUnit(dest);
133
vector.
AddInformationElement
(perr);
134
}
135
Ptr<Packet>
packet =
Create<Packet>
();
136
packet->AddHeader(vector);
137
uint32_t
size = vector.
GetSerializedSize
();
138
MeshInformationElementVector
resultVector;
139
packet->RemoveHeader(resultVector, size);
140
NS_TEST_ASSERT_MSG_EQ
(vector,
141
resultVector,
142
"Roundtrip serialization of all known information elements works"
);
143
}
144
145
/**
146
* @ingroup mesh-test
147
*
148
* @brief Mesh Test Suite
149
*/
150
class
MeshTestSuite
:
public
TestSuite
151
{
152
public
:
153
MeshTestSuite
();
154
};
155
156
MeshTestSuite::MeshTestSuite
()
157
:
TestSuite
(
"devices-mesh"
,
Type
::UNIT)
158
{
159
AddTestCase
(
new
MeshInformationElementVectorBist
, TestCase::Duration::QUICK);
160
}
161
162
static
MeshTestSuite
g_meshTestSuite
;
///< the test suite
MeshTestSuite
Mesh Test Suite.
Definition
mesh-information-element-vector-test-suite.cc:151
MeshTestSuite::MeshTestSuite
MeshTestSuite()
Definition
mesh-information-element-vector-test-suite.cc:156
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:1344
g_meshTestSuite
static MeshTestSuite g_meshTestSuite
the test suite
Definition
mesh-information-element-vector-test-suite.cc:162
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:47
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 Dec 13 2024 09:20:46 for ns-3 by
1.11.0