A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ie-dot11s-perr.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#include "ie-dot11s-perr.h"
10
11#include "ns3/address-utils.h"
12#include "ns3/packet.h"
13
14namespace ns3
15{
16namespace dot11s
17{
21
25
28{
29 return IE_PERR;
30}
31
32void
33IePerr::Print(std::ostream& os) const
34{
35 os << "PERR=(Number of failed destinations=" << m_addressUnits.size();
36 for (unsigned int j = 0; j < m_addressUnits.size(); j++)
37 {
38 os << "(Failed destination address=" << m_addressUnits[j].destination
39 << ", sequence number = " << m_addressUnits[j].seqnum << ")";
40 }
41 os << ")";
42}
43
44uint8_t
46{
47 return m_addressUnits.size();
48}
49
50void
52{
53 i.WriteU8(0); // TTL
54 i.WriteU8(m_addressUnits.size()); // number of Destinations
55 for (unsigned int j = 0; j < m_addressUnits.size(); j++)
56 {
57 i.WriteU8(0); // not used // Bit 6: AE (Address Extension) subfield (1 = destination
58 // external address is present, 0 = otherwise).
59 WriteTo(i, m_addressUnits[j].destination);
60 i.WriteHtolsbU32(m_addressUnits[j].seqnum);
61 i.WriteU8(0);
62 i.WriteU8(0);
63 }
64}
65
66uint16_t
68{
69 Buffer::Iterator i = start;
70 i.Next(1); // TTL //Mode flags is not used now
71 uint8_t numOfDest = i.ReadU8();
72 NS_ABORT_UNLESS((2 + 13 * numOfDest) == length);
73
74 for (unsigned int j = 0; j < numOfDest; j++)
75 {
76 i.Next(1); // flags is not used now
78 ReadFrom(i, unit.destination);
79 unit.seqnum = i.ReadLsbtohU32();
80 m_addressUnits.push_back(unit);
81 i.Next(2); // Reason
82 }
83 return i.GetDistanceFrom(start);
84}
85
86uint16_t
88{
89 uint16_t retval = 1 // TTL //ModeFlags
90 + 1 // NumOfDests
91 + 1 * m_addressUnits.size() // ModeFlags
92 + (6 + 4) * m_addressUnits.size() + 2 * m_addressUnits.size(); // Reason Code
93 return retval;
94}
95
96void
98{
99 for (unsigned int i = 0; i < m_addressUnits.size(); i++)
100 {
101 if (m_addressUnits[i].destination == unit.destination)
102 {
103 return;
104 }
105 }
106 if ((m_addressUnits.size() + 1) * 13 + 2 > 255)
107 {
108 return;
109 }
110 m_addressUnits.push_back(unit);
111}
112
113bool
115{
116 // -fstrict-overflow sensitive, see bug 1868
117 return (GetInformationFieldSize() > 255 - 2 /* ID + LENGTH*/
118 -
119 13 // 10 /* Size of Mac48Address + uint32_t (one unit)*/
120 );
121}
122
123std::vector<HwmpProtocol::FailedDestination>
125{
126 return m_addressUnits;
127}
128
129void
131{
132 for (auto i = m_addressUnits.begin(); i != m_addressUnits.end(); i++)
133 {
134 if (i->destination == address)
135 {
136 m_addressUnits.erase(i);
137 break;
138 }
139 }
140}
141
142void
144{
145 m_addressUnits.clear();
146}
147
148bool
149operator==(const IePerr& a, const IePerr& b)
150{
151 if (a.m_addressUnits.size() != b.m_addressUnits.size())
152 {
153 return false;
154 }
155 for (unsigned int i = 0; i < a.m_addressUnits.size(); i++)
156 {
157 if (a.m_addressUnits[i].destination != b.m_addressUnits[i].destination)
158 {
159 return false;
160 }
161 if (a.m_addressUnits[i].seqnum != b.m_addressUnits[i].seqnum)
162 {
163 return false;
164 }
165 }
166 return true;
167}
168
169std::ostream&
170operator<<(std::ostream& os, const IePerr& a)
171{
172 a.Print(os);
173 return os;
174}
175} // namespace dot11s
176} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
void WriteHtolsbU32(uint32_t data)
Definition buffer.cc:899
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
uint32_t ReadLsbtohU32()
Definition buffer.cc:1065
void Next()
go forward by one byte
Definition buffer.h:842
an EUI-48 address
See 7.3.2.98 of 802.11s draft 2.07.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
void SerializeInformationField(Buffer::Iterator i) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
void DeleteAddressUnit(Mac48Address address)
Delete address unit function.
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool IsFull() const
Is full function.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void ResetPerr()
Reset PERR.
void AddAddressUnit(HwmpProtocol::FailedDestination unit)
Add address unit function.
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint8_t GetNumOfDest() const
Get number of destination function.
std::vector< HwmpProtocol::FailedDestination > GetAddressUnitVector() const
Get address unit vector function.
std::vector< HwmpProtocol::FailedDestination > m_addressUnits
address units
#define NS_ABORT_UNLESS(cond)
Abnormal program termination if a condition is false.
Definition abort.h:118
bool operator==(const MeshHeader &a, const MeshHeader &b)
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
structure of unreachable destination - address and sequence number
Mac48Address destination
destination address
#define IE_PERR