author | Kirill Andreev <andreev@iitp.ru> |
Wed, 08 Apr 2009 20:58:40 +0400 | |
changeset 4951 | acaf07eb8542 |
parent 4945 | e64c6bfd8536 |
child 5004 | 29928e8d1a1c |
permissions | -rw-r--r-- |
4793 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008,2009 IITP RAS |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 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 |
* Author: Kirill Andreev <andreev@iitp.ru> |
|
19 |
*/ |
|
20 |
||
21 |
||
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
22 |
#include "ie-dot11s-beacon-timing.h" |
4834 | 23 |
#include "ns3/log.h" |
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
24 |
#include "ns3/test.h" |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
25 |
#include "ns3/packet.h" |
4793 | 26 |
namespace ns3 { |
4872 | 27 |
namespace dot11s { |
4793 | 28 |
/******************************************* |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
29 |
* IeBeaconTimingUnit |
4793 | 30 |
*******************************************/ |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
31 |
IeBeaconTimingUnit::IeBeaconTimingUnit (): |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
32 |
m_aid (0), |
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
33 |
m_lastBeacon (0), |
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
34 |
m_beaconInterval (0) |
4793 | 35 |
{ |
36 |
} |
|
37 |
||
38 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
39 |
IeBeaconTimingUnit::SetAid (uint8_t aid) |
4793 | 40 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
41 |
m_aid = aid; |
4793 | 42 |
} |
43 |
||
44 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
45 |
IeBeaconTimingUnit::SetLastBeacon (uint16_t lastBeacon) |
4793 | 46 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
47 |
m_lastBeacon = lastBeacon; |
4793 | 48 |
} |
49 |
||
50 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
51 |
IeBeaconTimingUnit::SetBeaconInterval (uint16_t beaconInterval) |
4793 | 52 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
53 |
m_beaconInterval = beaconInterval; |
4793 | 54 |
} |
55 |
||
56 |
uint8_t |
|
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
57 |
IeBeaconTimingUnit::GetAid () const |
4793 | 58 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
59 |
return m_aid; |
4793 | 60 |
} |
61 |
||
62 |
uint16_t |
|
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
63 |
IeBeaconTimingUnit::GetLastBeacon () const |
4793 | 64 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
65 |
return m_lastBeacon; |
4793 | 66 |
} |
67 |
||
68 |
uint16_t |
|
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
69 |
IeBeaconTimingUnit::GetBeaconInterval () const |
4793 | 70 |
{ |
4850
c3ee1deaa07a
Code refactoring: fixed names, added references to draft
Kirill Andreev <andreev@iitp.ru>
parents:
4847
diff
changeset
|
71 |
return m_beaconInterval; |
4793 | 72 |
} |
73 |
/******************************************* |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
74 |
* IeBeaconTiming |
4793 | 75 |
*******************************************/ |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
76 |
IeBeaconTiming::IeBeaconTiming (): |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
77 |
m_numOfUnits (0) |
4793 | 78 |
{ |
79 |
} |
|
80 |
||
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
81 |
IeBeaconTiming::NeighboursTimingUnitsList |
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
82 |
IeBeaconTiming::GetNeighboursTimingElementsList () |
4793 | 83 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
84 |
return m_neighbours; |
4793 | 85 |
} |
86 |
||
87 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
88 |
IeBeaconTiming::AddNeighboursTimingElementUnit ( |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
89 |
uint16_t aid, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
90 |
Time last_beacon, //MicroSeconds! |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
91 |
Time beacon_interval //MicroSeconds! |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
92 |
) |
4793 | 93 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
94 |
if (m_numOfUnits == 50) |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
95 |
return; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
96 |
//Firs we lookup if this element already exists |
4945 | 97 |
for (NeighboursTimingUnitsList::const_iterator i = m_neighbours.begin (); i != m_neighbours.end(); i++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
98 |
if ( |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
99 |
((*i)->GetAid () == AidToU8(aid)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
100 |
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
101 |
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
102 |
) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
103 |
return; |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
104 |
Ptr<IeBeaconTimingUnit>new_element = Create<IeBeaconTimingUnit> (); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
105 |
new_element->SetAid (AidToU8(aid)); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
106 |
new_element->SetLastBeacon (TimestampToU16(last_beacon)); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
107 |
new_element->SetBeaconInterval (BeaconIntervalToU16(beacon_interval)); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
108 |
m_neighbours.push_back (new_element); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
109 |
m_numOfUnits++; |
4793 | 110 |
} |
111 |
||
112 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
113 |
IeBeaconTiming::DelNeighboursTimingElementUnit ( |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
114 |
uint16_t aid, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
115 |
Time last_beacon, //MicroSeconds! |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
116 |
Time beacon_interval //MicroSeconds! |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
117 |
) |
4793 | 118 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
119 |
for (NeighboursTimingUnitsList::iterator i = m_neighbours.begin (); i != m_neighbours.end(); i++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
120 |
if ( |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
121 |
((*i)->GetAid () == AidToU8(aid)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
122 |
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
123 |
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
124 |
) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
125 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
126 |
m_neighbours.erase (i); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
127 |
m_numOfUnits--; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
128 |
break; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
129 |
} |
4793 | 130 |
} |
131 |
||
132 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
133 |
IeBeaconTiming::ClearTimingElement () |
4793 | 134 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
135 |
uint16_t to_delete = 0; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
136 |
uint16_t i; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
137 |
for (NeighboursTimingUnitsList::iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
138 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
139 |
to_delete++; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
140 |
(*j) = 0; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
141 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
142 |
for (i = 0; i < to_delete; i ++) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
143 |
m_neighbours.pop_back (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
144 |
m_neighbours.clear (); |
4793 | 145 |
|
146 |
} |
|
147 |
||
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4835
diff
changeset
|
148 |
uint8_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
149 |
IeBeaconTiming::GetInformationSize () const |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
150 |
{ |
4834 | 151 |
return (5*m_numOfUnits); |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
152 |
} |
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
153 |
|
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
154 |
void |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
155 |
IeBeaconTiming::PrintInformation (std::ostream& os) const |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
156 |
{ |
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
157 |
os <<"Number of units: " << (uint16_t)m_numOfUnits << "\n"; |
4861 | 158 |
for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++) |
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
159 |
os<< "AID=" << (uint16_t)(*j)->GetAid () << ", Last beacon was at " |
4861 | 160 |
<< (*j)->GetLastBeacon ()<<", with beacon interval " << (*j)->GetBeaconInterval () << "\n"; |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
161 |
} |
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
162 |
|
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
163 |
void |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
164 |
IeBeaconTiming::SerializeInformation (Buffer::Iterator i) const |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
165 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
166 |
for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
167 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
168 |
i.WriteU8 ((*j)->GetAid ()); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
169 |
i.WriteHtonU16 ((*j)->GetLastBeacon ()); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
170 |
i.WriteHtonU16 ((*j)->GetBeaconInterval ()); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
171 |
} |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
172 |
} |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4835
diff
changeset
|
173 |
uint8_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
174 |
IeBeaconTiming::DeserializeInformation (Buffer::Iterator start, uint8_t length) |
4793 | 175 |
{ |
4831
6a2923d9f526
Restructured beacon timing element
Kirill Andreev <andreev@iitp.ru>
parents:
4824
diff
changeset
|
176 |
Buffer::Iterator i = start; |
4834 | 177 |
m_numOfUnits = length/5; |
178 |
for (int j = 0; j < m_numOfUnits; j ++) |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
179 |
{ |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
180 |
Ptr<IeBeaconTimingUnit> new_element = Create<IeBeaconTimingUnit> (); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
181 |
new_element->SetAid (i.ReadU8()); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
182 |
new_element->SetLastBeacon (i.ReadNtohU16()); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
183 |
new_element->SetBeaconInterval (i.ReadNtohU16()); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
184 |
m_neighbours.push_back (new_element); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
185 |
} |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
186 |
return i.GetDistanceFrom (start); |
4793 | 187 |
}; |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
188 |
|
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
189 |
uint16_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
190 |
IeBeaconTiming::TimestampToU16 (Time x) |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
191 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
192 |
return ((uint16_t) ((x.GetMicroSeconds() >> 8)&0xffff)); |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
193 |
}; |
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
194 |
|
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
195 |
uint16_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
196 |
IeBeaconTiming::BeaconIntervalToU16 (Time x) |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
197 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
198 |
return ((uint16_t) (x.GetMicroSeconds() >>10)&0xffff); |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
199 |
}; |
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
200 |
|
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
201 |
uint8_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
202 |
IeBeaconTiming::AidToU8 (uint16_t x) |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
203 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4850
diff
changeset
|
204 |
return (uint8_t) (x&0xff); |
4819
f752215a847b
Move inline code, codestyle fix
Aleksey Kovalenko <kovalenko@iitp.ru>
parents:
4813
diff
changeset
|
205 |
}; |
4951
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
206 |
|
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
207 |
bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
208 |
{ |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
209 |
return ( |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
210 |
(a.GetAid () == b.GetAid ()) && |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
211 |
(a.GetLastBeacon () == b.GetLastBeacon()) && |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
212 |
(a.GetBeaconInterval () == b.GetBeaconInterval ()) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
213 |
); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
214 |
} |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
215 |
bool operator== (const IeBeaconTiming & a, const IeBeaconTiming& b) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
216 |
{ |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
217 |
if(a.m_numOfUnits != b.m_numOfUnits) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
218 |
return false; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
219 |
for(unsigned int i = 0; i < a.m_neighbours.size (); i ++) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
220 |
if(!(*PeekPointer(a.m_neighbours[i]) == *PeekPointer(b.m_neighbours[i]))) |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
221 |
return false; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
222 |
return true; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
223 |
} |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
224 |
|
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
225 |
#ifdef RUN_SELF_TESTS |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
226 |
struct IeBeaconTimingBist : public Test |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
227 |
{ |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
228 |
IeBeaconTimingBist () : Test ("Mesh/802.11s/IE/BeaconTiming") {} |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
229 |
virtual bool RunTests(); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
230 |
}; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
231 |
|
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
232 |
/// Test instance |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
233 |
static IeBeaconTimingBist g_IePerrBist; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
234 |
|
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
235 |
bool IeBeaconTimingBist::RunTests () |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
236 |
{ |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
237 |
bool result(true); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
238 |
// create test information element |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
239 |
IeBeaconTiming a; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
240 |
a.IeBeaconTiming::AddNeighboursTimingElementUnit (1,Seconds(1.0), Seconds(4.0)); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
241 |
a.IeBeaconTiming::AddNeighboursTimingElementUnit (2,Seconds(2.0), Seconds(3.0)); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
242 |
a.IeBeaconTiming::AddNeighboursTimingElementUnit (3,Seconds(3.0), Seconds(2.0)); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
243 |
a.IeBeaconTiming::AddNeighboursTimingElementUnit (4,Seconds(4.0), Seconds(1.0)); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
244 |
Ptr<Packet> packet = Create<Packet> (); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
245 |
packet->AddHeader(a); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
246 |
IeBeaconTiming b; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
247 |
packet->RemoveHeader(b); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
248 |
NS_TEST_ASSERT_EQUAL (a, b); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
249 |
//Test Find First |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
250 |
packet->AddHeader (a); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
251 |
IeBeaconTiming c; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
252 |
bool ok = c.FindFirst(packet); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
253 |
NS_TEST_ASSERT (ok); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
254 |
NS_TEST_ASSERT_EQUAL (a, c); |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
255 |
return result; |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
256 |
} |
acaf07eb8542
Unit testing for dot11s-IE
Kirill Andreev <andreev@iitp.ru>
parents:
4945
diff
changeset
|
257 |
#endif |
4872 | 258 |
} // namespace dot11s |
4793 | 259 |
} //namespace ns3 |
4872 | 260 |