src/devices/mesh/dot11s/peer-management-plugin.cc
author Kirill Andreev <andreev@iitp.ru>
Thu, 02 Apr 2009 13:38:38 +0400
changeset 4933 72f0481cfb2d
parent 4919 b8a0476c7e06
child 4949 c376fb558264
permissions -rw-r--r--
Peer link restructured to support multi-interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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; -*- */
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     2
/* 
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     4
 * 
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
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    17
 * 
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"
4882
3eab2f6b1adc Moved hwmp to dot11s, removed unneded files, removed unneded headers from
Kirill Andreev <andreev@iitp.ru>
parents: 4881
diff changeset
    23
#include "peer-management-plugin.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
    24
#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
    25
#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
    26
#include "ns3/mesh-wifi-interface-mac.h"
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    27
#include "ns3/mesh-wifi-mac-header.h"
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    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"
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    30
#include "ns3/mesh-wifi-mac-header.h"
4860
bb5194d57734 New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents: 4859
diff changeset
    31
#include "ns3/log.h"
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    32
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    33
NS_LOG_COMPONENT_DEFINE("PeerManager");
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    34
namespace ns3 {
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
    35
namespace dot11s {
4919
b8a0476c7e06 Added unicast PREQ, peer link status callback.
Kirill Andreev <andreev@iitp.ru>
parents: 4895
diff changeset
    36
PeerManagerMacPlugin::PeerManagerMacPlugin (uint32_t interface, Ptr<PeerManagementProtocol> protocol)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    37
{
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    38
  m_ifIndex = interface;
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    39
  m_protocol = protocol;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    40
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    41
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    42
PeerManagerMacPlugin::~PeerManagerMacPlugin ()
4856
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
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    46
void
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    47
PeerManagerMacPlugin::SetParent (Ptr<MeshWifiInterfaceMac> parent)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    48
{
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    49
  m_parent = parent;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    50
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    52
bool
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
    53
PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & header)
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    54
{
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
    55
  // 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
    56
  //headers
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
    57
  Ptr<Packet> packet = const_packet->Copy();
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    58
  if(header.IsBeacon())
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    59
  {
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
    60
    IeBeaconTiming beaconTiming;
4858
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    61
    Ptr<Packet> myBeacon = packet->Copy();
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    62
    MgtBeaconHeader beacon_hdr;
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
    63
    myBeacon->RemoveHeader(beacon_hdr);
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    64
    bool meshBeacon = false;
4874
f7ea3717e668 Code cleanups. Software delay is removed
Kirill Andreev <andreev@iitp.ru>
parents: 4873
diff changeset
    65
    if(beaconTiming.FindFirst(myBeacon))
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    66
      meshBeacon = true;
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
    67
    m_protocol->UpdatePeerBeaconTiming(
4861
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    68
        m_ifIndex,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    69
        meshBeacon,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    70
        beaconTiming,
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    71
        header.GetAddr2(),
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    72
        Simulator::Now(),
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    73
        MicroSeconds(beacon_hdr.GetBeaconIntervalUs())
20d333d95df2 Neighbours are attached
Kirill Andreev <andreev@iitp.ru>
parents: 4860
diff changeset
    74
        );
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
    75
    // Beacon shall not be dropeed. May be needed to another plugins
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    76
    return true;
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4856
diff changeset
    77
  }
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    78
  if(header.IsMultihopAction())
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    79
  {
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    80
    WifiMeshHeader meshHdr;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    81
    packet->RemoveHeader (meshHdr);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    82
    WifiMeshMultihopActionHeader multihopHdr;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    83
    //parse multihop action header:
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    84
    packet->RemoveHeader (multihopHdr);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    85
    WifiMeshMultihopActionHeader::ACTION_VALUE actionValue = multihopHdr.GetAction ();
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
    86
    // If can not handle - just return;
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4861
diff changeset
    87
    if(multihopHdr.GetCategory () != WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT)
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
    88
      return true;
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
    89
    NS_ASSERT(meshHdr.GetMeshTtl () == 1);
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
    90
    NS_ASSERT(meshHdr.GetAddressExt () == 1);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    91
    Mac48Address peerAddress = header.GetAddr2 ();
4933
72f0481cfb2d Peer link restructured to support multi-interface
Kirill Andreev <andreev@iitp.ru>
parents: 4919
diff changeset
    92
    Mac48Address peerMpAddress = meshHdr.GetAddr4 ();
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    93
    PeerLinkFrameStart::PlinkFrameStartFields fields;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    94
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    95
      PeerLinkFrameStart peerFrame;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    96
      packet->RemoveHeader (peerFrame);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    97
      fields = peerFrame.GetFields();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    98
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
    99
    if (actionValue.peerLink != WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   100
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   101
      if(!(m_parent->CheckSupportedRates(fields.rates)))
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   102
      {
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   103
        m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   104
        // Broken peer link frame - drop it
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   105
        return false;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   106
      }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   107
      if (!fields.meshId.IsEqual(m_parent->GetSsid()))
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   108
      {
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   109
        m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   110
        // Broken peer link frame - drop it
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   111
        return true;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   112
      }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   113
    }
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   114
    // MeshConfiguration Element - exists in all peer link management
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   115
    // frames except CLOSE
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   116
    IeConfiguration meshConfig;
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   117
    if(fields.subtype != IePeerManagement::PEER_CLOSE)
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4892
diff changeset
   118
      packet->RemoveHeader(meshConfig);
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   119
    IePeerManagement peerElement;
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   120
    packet->RemoveHeader(peerElement);
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   121
    // Check the correspondance betwee action valuse and peer link
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   122
    // management element subtypes:
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   123
    switch (actionValue.peerLink)
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   124
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   125
      case WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   126
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_CONFIRM);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   127
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   128
      case WifiMeshMultihopActionHeader::PEER_LINK_OPEN:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   129
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_OPEN);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   130
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   131
      case WifiMeshMultihopActionHeader::PEER_LINK_CLOSE:
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   132
        NS_ASSERT(fields.subtype == IePeerManagement::PEER_CLOSE);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   133
        break;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   134
      default:
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   135
        // Protocol can not define which frame is it - pass further
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   136
        return true;
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   137
    }
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   138
    //Deliver Peer link management frame to protocol:
4933
72f0481cfb2d Peer link restructured to support multi-interface
Kirill Andreev <andreev@iitp.ru>
parents: 4919
diff changeset
   139
    m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, meshConfig);
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   140
    // if we can handle a frame - drop it
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   141
    return false;
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
   142
  }
4895
b68a1309a89e First PREQ delivered
Kirill Andreev <andreev@iitp.ru>
parents: 4892
diff changeset
   143
  return m_protocol->IsActiveLink(m_ifIndex,header.GetAddr2());
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   144
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   145
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   146
bool
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   147
PeerManagerMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   148
{
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   149
  return true;
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   150
}
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   151
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   152
void
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   153
PeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   154
{
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   155
  Ptr<IeBeaconTiming>  beaconTiming = m_protocol->GetBeaconTimingElement(m_ifIndex);
4858
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   156
  beacon.AddInformationElement(beaconTiming);
4856
b7241df728a3 Added PM-mac - not implemented
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   157
}
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   158
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   159
void
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   160
PeerManagerMacPlugin::SendPeerLinkManagementFrame(
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   161
      Mac48Address peerAddress,
4933
72f0481cfb2d Peer link restructured to support multi-interface
Kirill Andreev <andreev@iitp.ru>
parents: 4919
diff changeset
   162
      Mac48Address peerMpAddress,
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   163
      uint16_t aid,
4876
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   164
      IePeerManagement peerElement,
d78f1b978dac Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4874
diff changeset
   165
      IeConfiguration meshConfig
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   166
      )
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   167
{
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   168
  //Create a packet:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   169
  Ptr<Packet> packet = Create<Packet> ();
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   170
  packet->AddHeader (peerElement);
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   171
  if(!peerElement.SubtypeIsClose())
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   172
    packet->AddHeader (meshConfig);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   173
  PeerLinkFrameStart::PlinkFrameStartFields fields;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   174
  fields.subtype = peerElement.GetSubtype();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   175
  fields.aid = aid;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   176
  fields.rates = m_parent->GetSupportedRates ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   177
  fields.meshId = m_parent->GetSsid ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   178
  PeerLinkFrameStart plinkFrame;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   179
  plinkFrame.SetPlinkFrameStart(fields);
4867
3a02e4e89292 Finished processing peer link frames on new architeture
Kirill Andreev <andreev@iitp.ru>
parents: 4866
diff changeset
   180
  packet->AddHeader (plinkFrame);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   181
  //Create an 802.11 frame header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   182
  //Send management frame to MAC:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   183
  WifiMeshMultihopActionHeader multihopHdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   184
  if (peerElement.SubtypeIsOpen ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   185
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   186
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   187
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_OPEN;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   188
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   189
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   190
  if (peerElement.SubtypeIsConfirm ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   191
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   192
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   193
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   194
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   195
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   196
  if (peerElement.SubtypeIsClose ())
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   197
    {
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   198
      WifiMeshMultihopActionHeader::ACTION_VALUE action;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   199
      action.peerLink = WifiMeshMultihopActionHeader::PEER_LINK_CLOSE;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   200
      multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT, action);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   201
    }
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   202
  packet->AddHeader (multihopHdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   203
  //mesh header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   204
  WifiMeshHeader meshHdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   205
  meshHdr.SetMeshTtl (1);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   206
  meshHdr.SetMeshSeqno (0);
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4887
diff changeset
   207
  meshHdr.SetAddressExt(1);
4933
72f0481cfb2d Peer link restructured to support multi-interface
Kirill Andreev <andreev@iitp.ru>
parents: 4919
diff changeset
   208
  meshHdr.SetAddr4(m_protocol->GetAddress ());
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   209
  packet->AddHeader (meshHdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   210
  //Wifi Mac header:
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   211
  WifiMacHeader hdr;
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   212
  hdr.SetMultihopAction ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   213
  hdr.SetAddr1 (peerAddress);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   214
  hdr.SetAddr2 (m_parent->GetAddress ());
4933
72f0481cfb2d Peer link restructured to support multi-interface
Kirill Andreev <andreev@iitp.ru>
parents: 4919
diff changeset
   215
  hdr.SetAddr3 (peerMpAddress);
4866
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   216
  hdr.SetDsNotFrom ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   217
  hdr.SetDsNotTo ();
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   218
  m_parent->SendManagementFrame(packet, hdr);
564372fc5491 First management frame goes through new archotecture
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   219
}
4881
cec7f8e2bbdf Minor cosmetics. Peer management protocol is assumed to be implemented now.
Pavel Boyko <boyko@iitp.ru>
parents: 4879
diff changeset
   220
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   221
Mac48Address
4873
3e5607e26273 Dot11s prefix removed
Kirill Andreev <andreev@iitp.ru>
parents: 4872
diff changeset
   222
PeerManagerMacPlugin::GetAddress () const
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   223
{
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   224
  if(m_parent !=  0)
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   225
    return m_parent->GetAddress ();
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   226
  else return Mac48Address::Mac48Address();
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4867
diff changeset
   227
}
4879
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   228
std::pair<Time, Time> 
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   229
PeerManagerMacPlugin::GetBeaconInfo() const
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   230
{
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   231
  std::pair<Time,Time> retval;
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   232
  retval.first = m_parent->GetTbtt ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   233
  retval.second = m_parent->GetBeaconInterval ();
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   234
  return retval;
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   235
}
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   236
void
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   237
PeerManagerMacPlugin::SetBeaconShift(Time shift)
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   238
{
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   239
  m_parent->ShiftTbtt (shift);
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   240
}
597d1e0a4bb5 BCA works again
Kirill Andreev <andreev@iitp.ru>
parents: 4877
diff changeset
   241
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   242
} // namespace dot11s
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   243
} //namespace ns3
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4871
diff changeset
   244