author | Kirill Andreev <andreev@iitp.ru> |
Thu, 20 Aug 2009 18:24:23 +0400 | |
changeset 5154 | bb06787ed7fe |
parent 5140 | 64084ae6cff1 |
child 5157 | ace422ad12df |
permissions | -rw-r--r-- |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
5129 | 2 |
/* |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 IITP RAS |
5129 | 4 |
* |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
8 |
* |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
13 |
* |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5129 | 17 |
* |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
19 |
*/ |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
20 |
|
4860
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4859
diff
changeset
|
21 |
#include "ie-dot11s-configuration.h" |
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4859
diff
changeset
|
22 |
#include "ie-dot11s-peer-management.h" |
4956
aba7cae978ac
MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents:
4953
diff
changeset
|
23 |
#include "dot11s-mac-header.h" |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
24 |
#include "peer-management-protocol-mac.h" |
4887
cbf02c77d5c1
HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents:
4882
diff
changeset
|
25 |
#include "peer-management-protocol.h" |
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
26 |
#include "peer-link-frame.h" |
4887
cbf02c77d5c1
HWMP is attached to mesh point device and MAC layer with zero functionality
Kirill Andreev <andreev@iitp.ru>
parents:
4882
diff
changeset
|
27 |
#include "ns3/mesh-wifi-interface-mac.h" |
4861 | 28 |
#include "ns3/simulator.h" |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
29 |
#include "ns3/wifi-mac-header.h" |
5140
64084ae6cff1
Removed FindFirst from WifiInformationElement
Kirill Andreev <andreev@iitp.ru>
parents:
5139
diff
changeset
|
30 |
#include "ns3/wifi-information-element-vector.h" |
5139
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
31 |
#include "ns3/log.h" |
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
32 |
namespace ns3 { |
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
33 |
namespace dot11s { |
5129 | 34 |
PeerManagementProtocolMac::PeerManagementProtocolMac (uint32_t interface, |
35 |
Ptr<PeerManagementProtocol> protocol) |
|
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
36 |
{ |
4861 | 37 |
m_ifIndex = interface; |
38 |
m_protocol = protocol; |
|
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
39 |
} |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
40 |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
41 |
PeerManagementProtocolMac::~PeerManagementProtocolMac () |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
42 |
{ |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
43 |
} |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
44 |
|
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
45 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
46 |
PeerManagementProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent) |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
47 |
{ |
4857
ddfb13420455
Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents:
4856
diff
changeset
|
48 |
m_parent = parent; |
5154
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
49 |
m_parent->TraceConnectWithoutContext ("TxErrHeader", MakeCallback (&PeerManagementProtocolMac::TxError, this)); |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
50 |
m_parent->TraceConnectWithoutContext ("TxOkHeader", MakeCallback (&PeerManagementProtocolMac::TxOk, this)); |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
51 |
} |
5154
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
52 |
void |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
53 |
PeerManagementProtocolMac::TxError (WifiMacHeader const &hdr) |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
54 |
{ |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
55 |
m_protocol->TransmissionFailure (m_ifIndex, hdr.GetAddr1 ()); |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
56 |
} |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
57 |
void |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
58 |
PeerManagementProtocolMac::TxOk (WifiMacHeader const &hdr) |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
59 |
{ |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
60 |
m_protocol->TransmissionSuccess (m_ifIndex, hdr.GetAddr1 ()); |
bb06787ed7fe
Added closing link due to transmission failure.
Kirill Andreev <andreev@iitp.ru>
parents:
5140
diff
changeset
|
61 |
} |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
62 |
bool |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
63 |
PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header) |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
64 |
{ |
4881
cec7f8e2bbdf
Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents:
4879
diff
changeset
|
65 |
// First of all we copy a packet, because we need to remove some |
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
66 |
//headers |
5129 | 67 |
Ptr<Packet> packet = const_packet->Copy (); |
68 |
if (header.IsBeacon ()) |
|
69 |
{ |
|
70 |
MgtBeaconHeader beacon_hdr; |
|
5139
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
71 |
packet->RemoveHeader (beacon_hdr); |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
72 |
//meshId.FindFirst (myBeacon); |
5129 | 73 |
bool meshBeacon = false; |
5139
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
74 |
WifiInformationElementVector elements = WifiInformationElementVector::DeserializePacket (packet); |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
75 |
Ptr<IeBeaconTiming> beaconTiming = DynamicCast<IeBeaconTiming> (elements.FindFirst (IE11S_BEACON_TIMING)); |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
76 |
Ptr<IeMeshId> meshId = DynamicCast<IeMeshId> (elements.FindFirst (IE11S_MESH_ID)); |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
77 |
|
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
78 |
if ((beaconTiming != 0) && (meshId != 0)) |
5129 | 79 |
{ |
5139
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
80 |
if (m_protocol->GetMeshId ()->IsEqual (*meshId)) |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
81 |
{ |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
82 |
meshBeacon = true; |
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
83 |
} |
5129 | 84 |
} |
5139
87eb2f77f661
Added wifi-information-element-vector
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
85 |
m_protocol->UpdatePeerBeaconTiming (m_ifIndex, meshBeacon, *beaconTiming, header.GetAddr2 (), |
5129 | 86 |
Simulator::Now (), MicroSeconds (beacon_hdr.GetBeaconIntervalUs ())); |
87 |
// Beacon shall not be dropeed. May be needed to another plugins |
|
88 |
return true; |
|
89 |
} |
|
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
90 |
if (header.IsAction ()) |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
91 |
{ |
5129 | 92 |
WifiMeshActionHeader actionHdr; |
93 |
packet->RemoveHeader (actionHdr); |
|
94 |
WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
|
95 |
// If can not handle - just return; |
|
96 |
if (actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PEERING_MGT) |
|
97 |
{ |
|
98 |
return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ()); |
|
99 |
} |
|
100 |
m_stats.rxMgt++; |
|
101 |
m_stats.rxMgtBytes += packet->GetSize (); |
|
102 |
Mac48Address peerAddress = header.GetAddr2 (); |
|
103 |
Mac48Address peerMpAddress = header.GetAddr3 (); |
|
104 |
PeerLinkFrameStart::PlinkFrameStartFields fields; |
|
105 |
{ |
|
106 |
PeerLinkFrameStart peerFrame; |
|
107 |
peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.peerLink); |
|
108 |
packet->RemoveHeader (peerFrame); |
|
109 |
fields = peerFrame.GetFields (); |
|
110 |
NS_ASSERT (fields.subtype == actionValue.peerLink); |
|
111 |
} |
|
112 |
if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CLOSE) && !(m_parent->CheckSupportedRates ( |
|
113 |
fields.rates))) |
|
114 |
{ |
|
115 |
m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
|
116 |
// Broken peer link frame - drop it |
|
117 |
m_stats.brokenMgt++; |
|
118 |
return false; |
|
119 |
} |
|
120 |
if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CONFIRM) && !fields.meshId.IsEqual ( |
|
121 |
*(m_protocol->GetMeshId ()))) |
|
122 |
{ |
|
123 |
m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
|
124 |
// Broken peer link frame - drop it |
|
125 |
m_stats.brokenMgt++; |
|
126 |
return false; |
|
127 |
} |
|
128 |
IePeerManagement peerElement; |
|
129 |
packet->RemoveHeader (peerElement); |
|
130 |
//Check taht frame subtype corresponds peer link subtype |
|
131 |
if (peerElement.SubtypeIsOpen ()) |
|
132 |
{ |
|
133 |
m_stats.rxOpen++; |
|
134 |
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN); |
|
135 |
} |
|
136 |
if (peerElement.SubtypeIsConfirm ()) |
|
137 |
{ |
|
138 |
m_stats.rxConfirm++; |
|
139 |
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM); |
|
140 |
} |
|
141 |
if (peerElement.SubtypeIsClose ()) |
|
142 |
{ |
|
143 |
m_stats.rxClose++; |
|
144 |
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE); |
|
145 |
} |
|
146 |
//Deliver Peer link management frame to protocol: |
|
147 |
m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, |
|
148 |
fields.config); |
|
149 |
// if we can handle a frame - drop it |
|
150 |
return false; |
|
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
151 |
} |
5129 | 152 |
return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ()); |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
153 |
} |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
154 |
bool |
5129 | 155 |
PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, |
156 |
Mac48Address from, Mac48Address to) |
|
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
157 |
{ |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
158 |
if (header.IsAction ()) |
5129 | 159 |
{ |
160 |
WifiMeshActionHeader actionHdr; |
|
161 |
packet->PeekHeader (actionHdr); |
|
162 |
WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
|
163 |
if (actionHdr.GetCategory () == WifiMeshActionHeader::MESH_PEERING_MGT) |
|
164 |
{ |
|
165 |
return true; |
|
166 |
} |
|
167 |
} |
|
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
168 |
if (header.GetAddr1 ().IsGroup ()) |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
169 |
{ |
5012 | 170 |
return true; |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
171 |
} |
5129 | 172 |
else |
5012 | 173 |
{ |
5129 | 174 |
if (m_protocol->IsActiveLink (m_ifIndex, header.GetAddr1 ())) |
175 |
{ |
|
176 |
return true; |
|
177 |
} |
|
178 |
else |
|
179 |
{ |
|
180 |
m_stats.dropped++; |
|
181 |
return false; |
|
182 |
} |
|
5012 | 183 |
} |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
184 |
} |
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
185 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
186 |
PeerManagementProtocolMac::UpdateBeacon (MeshWifiBeacon & beacon) const |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
187 |
{ |
5129 | 188 |
Ptr<IeBeaconTiming> beaconTiming = m_protocol->GetBeaconTimingElement (m_ifIndex); |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
189 |
beacon.AddInformationElement (beaconTiming); |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
190 |
beacon.AddInformationElement (m_protocol->GetMeshId ()); |
4856
b7241df728a3
Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
191 |
} |
4881
cec7f8e2bbdf
Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents:
4879
diff
changeset
|
192 |
|
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
193 |
void |
5129 | 194 |
PeerManagementProtocolMac::SendPeerLinkManagementFrame (Mac48Address peerAddress, Mac48Address peerMpAddress, |
195 |
uint16_t aid, IePeerManagement peerElement, IeConfiguration meshConfig) |
|
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
196 |
{ |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
197 |
//Create a packet: |
5017
a2a6accbc167
Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents:
5015
diff
changeset
|
198 |
meshConfig.SetNeighborCount (m_protocol->GetNumberOfLinks ()); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
199 |
Ptr<Packet> packet = Create<Packet> (); |
4867
3a02e4e89292
Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents:
4866
diff
changeset
|
200 |
packet->AddHeader (peerElement); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
201 |
PeerLinkFrameStart::PlinkFrameStartFields fields; |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
202 |
fields.rates = m_parent->GetSupportedRates (); |
5023
fce378307409
Moving to IEEE 802.11s Draft 3.0:
Andrey Mazo <mazo@iitp.ru>
parents:
5020
diff
changeset
|
203 |
fields.capability = 0; |
5020
79e8178d69eb
Mesh ID is made separately from SSID
Kirill Andreev <andreev@iitp.ru>
parents:
5017
diff
changeset
|
204 |
fields.meshId = *(m_protocol->GetMeshId ()); |
4973
59b050ada622
Restructured peer link frame
Kirill Andreev <andreev@iitp.ru>
parents:
4970
diff
changeset
|
205 |
fields.config = meshConfig; |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
206 |
PeerLinkFrameStart plinkFrame; |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
207 |
//Create an 802.11 frame header: |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
208 |
//Send management frame to MAC: |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
209 |
WifiMeshActionHeader actionHdr; |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
210 |
if (peerElement.SubtypeIsOpen ()) |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
211 |
{ |
5129 | 212 |
m_stats.txOpen++; |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
213 |
WifiMeshActionHeader::ActionValue action; |
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
214 |
action.peerLink = WifiMeshActionHeader::PEER_LINK_OPEN; |
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
215 |
fields.subtype = WifiMeshActionHeader::PEER_LINK_OPEN; |
5027
2f926202a5bf
Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents:
5023
diff
changeset
|
216 |
actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
217 |
} |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
218 |
if (peerElement.SubtypeIsConfirm ()) |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
219 |
{ |
5129 | 220 |
m_stats.txConfirm++; |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
221 |
WifiMeshActionHeader::ActionValue action; |
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
222 |
action.peerLink = WifiMeshActionHeader::PEER_LINK_CONFIRM; |
4957
3ce177c38776
Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents:
4956
diff
changeset
|
223 |
fields.aid = aid; |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
224 |
fields.subtype = WifiMeshActionHeader::PEER_LINK_CONFIRM; |
5027
2f926202a5bf
Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents:
5023
diff
changeset
|
225 |
actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
226 |
} |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
227 |
if (peerElement.SubtypeIsClose ()) |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
228 |
{ |
5129 | 229 |
m_stats.txClose++; |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
230 |
WifiMeshActionHeader::ActionValue action; |
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
231 |
action.peerLink = WifiMeshActionHeader::PEER_LINK_CLOSE; |
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
232 |
fields.subtype = WifiMeshActionHeader::PEER_LINK_CLOSE; |
4957
3ce177c38776
Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents:
4956
diff
changeset
|
233 |
fields.reasonCode = peerElement.GetReasonCode (); |
5027
2f926202a5bf
Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents:
5023
diff
changeset
|
234 |
actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
235 |
} |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
236 |
plinkFrame.SetPlinkFrameStart (fields); |
4957
3ce177c38776
Resturctured peer link frame - removed unneeded field "subtype", added unit
Kirill Andreev <andreev@iitp.ru>
parents:
4956
diff
changeset
|
237 |
packet->AddHeader (plinkFrame); |
4984
77ab6e01a1c3
Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents:
4977
diff
changeset
|
238 |
packet->AddHeader (actionHdr); |
5129 | 239 |
m_stats.txMgt++; |
5038 | 240 |
m_stats.txMgtBytes += packet->GetSize (); |
4968
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4957
diff
changeset
|
241 |
// Wifi Mac header: |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
242 |
WifiMacHeader hdr; |
4968
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4957
diff
changeset
|
243 |
hdr.SetAction (); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
244 |
hdr.SetAddr1 (peerAddress); |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
245 |
hdr.SetAddr2 (m_parent->GetAddress ()); |
4970
320f59d9df27
Removed mesh header from acion management frames
Kirill Andreev <andreev@iitp.ru>
parents:
4968
diff
changeset
|
246 |
//Addr is not used here, we use it as our MP address |
320f59d9df27
Removed mesh header from acion management frames
Kirill Andreev <andreev@iitp.ru>
parents:
4968
diff
changeset
|
247 |
hdr.SetAddr3 (m_protocol->GetAddress ()); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
248 |
hdr.SetDsNotFrom (); |
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
249 |
hdr.SetDsNotTo (); |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
250 |
m_parent->SendManagementFrame (packet, hdr); |
4866
564372fc5491
First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents:
4865
diff
changeset
|
251 |
} |
4881
cec7f8e2bbdf
Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents:
4879
diff
changeset
|
252 |
|
4869 | 253 |
Mac48Address |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
254 |
PeerManagementProtocolMac::GetAddress () const |
4869 | 255 |
{ |
5129 | 256 |
if (m_parent != 0) |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
257 |
{ |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
258 |
return m_parent->GetAddress (); |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
259 |
} |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
260 |
else |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
261 |
{ |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
262 |
return Mac48Address::Mac48Address (); |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
263 |
} |
4869 | 264 |
} |
5129 | 265 |
std::pair<Time, Time> |
266 |
PeerManagementProtocolMac::GetBeaconInfo () const |
|
4879 | 267 |
{ |
5129 | 268 |
std::pair<Time, Time> retval; |
4879 | 269 |
retval.first = m_parent->GetTbtt (); |
270 |
retval.second = m_parent->GetBeaconInterval (); |
|
271 |
return retval; |
|
272 |
} |
|
273 |
void |
|
5129 | 274 |
PeerManagementProtocolMac::SetBeaconShift (Time shift) |
4879 | 275 |
{ |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
276 |
if (shift != Seconds (0)) |
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
277 |
{ |
5129 | 278 |
m_stats.beaconShift++; |
5125
b90c6c0af6a3
Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic
Kirill Andreev <andreev@iitp.ru>
parents:
5098
diff
changeset
|
279 |
} |
4879 | 280 |
m_parent->ShiftTbtt (shift); |
281 |
} |
|
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
282 |
PeerManagementProtocolMac::Statistics::Statistics () : |
5129 | 283 |
txOpen (0), txConfirm (0), txClose (0), rxOpen (0), rxConfirm (0), rxClose (0), dropped (0), brokenMgt (0), |
284 |
txMgt (0), txMgtBytes (0), rxMgt (0), rxMgtBytes (0), beaconShift (0) |
|
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
285 |
{ |
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
286 |
} |
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
287 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
288 |
PeerManagementProtocolMac::Statistics::Print (std::ostream & os) const |
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
289 |
{ |
5015 | 290 |
os << "<Statistics " |
5038 | 291 |
"txOpen=\"" << txOpen << "\"\n" |
292 |
"txConfirm=\"" << txConfirm << "\"\n" |
|
293 |
"txClose=\"" << txClose << "\"\n" |
|
294 |
"rxOpen=\"" << rxOpen << "\"\n" |
|
295 |
"rxConfirm=\"" << rxConfirm << "\"\n" |
|
296 |
"rxClose=\"" << rxClose << "\"\n" |
|
5015 | 297 |
"dropped=\"" << dropped << "\"\n" |
298 |
"brokenMgt=\"" << brokenMgt << "\"\n" |
|
5038 | 299 |
"txMgt=\"" << txMgt << "\"\n" |
5098
13ded9ff11c4
XML reports simplified for better parsing
Pavel Boyko <boyko@iitp.ru>
parents:
5087
diff
changeset
|
300 |
"txMgtBytes=\"" << txMgtBytes << "\"\n" |
5038 | 301 |
"rxMgt=\"" << rxMgt << "\"\n" |
5098
13ded9ff11c4
XML reports simplified for better parsing
Pavel Boyko <boyko@iitp.ru>
parents:
5087
diff
changeset
|
302 |
"rxMgtBytes=\"" << rxMgtBytes << "\"\n" |
5015 | 303 |
"beaconShift=\"" << beaconShift << "\"/>\n"; |
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
304 |
} |
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
305 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
306 |
PeerManagementProtocolMac::Report (std::ostream & os) const |
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
307 |
{ |
5087 | 308 |
os << "<PeerManagementProtocolMac " |
5015 | 309 |
"address=\"" << m_parent->GetAddress () << "\">\n"; |
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
310 |
m_stats.Print (os); |
5087 | 311 |
os << "</PeerManagementProtocolMac>\n"; |
5009
ac0ea6c1e012
Added statistics for PMP-MAC
Kirill Andreev <andreev@iitp.ru>
parents:
5002
diff
changeset
|
312 |
} |
5013 | 313 |
void |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
314 |
PeerManagementProtocolMac::ResetStats () |
5013 | 315 |
{ |
316 |
m_stats = Statistics::Statistics (); |
|
317 |
} |
|
5015 | 318 |
uint32_t |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5038
diff
changeset
|
319 |
PeerManagementProtocolMac::GetLinkMetric (Mac48Address peerAddress) |
5015 | 320 |
{ |
321 |
return m_parent->GetLinkMetric (peerAddress); |
|
322 |
} |
|
4872 | 323 |
} // namespace dot11s |
324 |
} //namespace ns3 |
|
325 |