A Discrete-Event Network Simulator
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
23using 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 */
37{
39 : TestCase("Serialization test for all mesh information elements"){};
40 void DoRun() override;
41};
42
43void
45{
47 {
48 // Mesh ID test
50 vector.AddInformationElement(meshId);
51 }
52 {
54 vector.AddInformationElement(config);
55 }
56 {
58 vector.AddInformationElement(report);
59 }
60 {
62 peerMan1->SetPeerOpen(1);
64 peerMan2->SetPeerConfirm(1, 2);
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 {
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 {
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 {
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 {
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 {
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);
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 */
148{
149 public:
151};
152
154 : TestSuite("devices-mesh", Type::UNIT)
155{
156 AddTestCase(new MeshInformationElementVectorBist, TestCase::Duration::QUICK);
157}
158
159static MeshTestSuite g_meshTestSuite; ///< the test suite
an EUI-48 address
bool AddInformationElement(Ptr< WifiInformationElement > element)
add an IE, if maxSize has exceeded, returns false
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
static MeshTestSuite g_meshTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Built-in self test for MeshInformationElementVector and all IE.
void DoRun() override
Implementation to actually run this TestCase.
structure of unreachable destination - address and sequence number
Mac48Address destination
destination address