src/devices/mesh/mesh-wifi-interface-mac.cc
author Kirill Andreev <andreev@iitp.ru>
Wed, 08 Apr 2009 18:17:33 +0400
changeset 4950 1163cfb03b9b
parent 4949 c376fb558264
child 4964 9107f67330f3
permissions -rw-r--r--
Broadcast is not forwarded twice into the same channel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
     2
/*
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
     4
 *
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     8
 *
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    13
 *
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
    17
 *
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    18
 * Authors: Kirill Andreev <andreev@iitp.ru>
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    19
 *          Pavel Boyko <boyko@iitp.ru>
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    20
 */
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    21
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    22
#include "ns3/mesh-wifi-interface-mac.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    23
#include "ns3/mesh-wifi-beacon.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    24
#include "ns3/log.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    25
#include "ns3/wifi-phy.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    26
#include "ns3/dcf-manager.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    27
#include "ns3/mac-rx-middle.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    28
#include "ns3/mac-low.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    29
#include "ns3/dca-txop.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    30
#include "ns3/random-variable.h"
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    31
#include "ns3/simulator.h"
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
    32
#include "ns3/yans-wifi-phy.h"
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    33
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    34
NS_LOG_COMPONENT_DEFINE ("MeshWifiInterfaceMac");
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    35
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    36
namespace ns3 {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    37
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    38
NS_OBJECT_ENSURE_REGISTERED (MeshWifiInterfaceMac);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    39
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    40
TypeId
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    41
MeshWifiInterfaceMac::GetTypeId ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    42
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    43
  static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac")
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    44
                      .SetParent<WifiMac> ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    45
                      .AddConstructor<MeshWifiInterfaceMac> ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    46
                      .AddAttribute ("BeaconInterval", "Beacon Interval",
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    47
                                     TimeValue (Seconds (1.0)),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    48
                                     MakeTimeAccessor (&MeshWifiInterfaceMac::m_beaconInterval),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    49
                                     MakeTimeChecker ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    50
                                    )
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    51
                      .AddAttribute ("RandomStart", "Window when beacon generating starts (uniform random) in seconds",
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    52
                                     TimeValue (Seconds (0.1)),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    53
                                     MakeTimeAccessor (&MeshWifiInterfaceMac::m_randomStart),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    54
                                     MakeTimeChecker ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    55
                                    )
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    56
                      .AddAttribute ("BeaconGeneration", "Enable/Disable Beaconing.",
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    57
                                     BooleanValue (true),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    58
                                     MakeBooleanAccessor (
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    59
                                       &MeshWifiInterfaceMac::SetBeaconGeneration,
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    60
                                       &MeshWifiInterfaceMac::GetBeaconGeneration
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    61
                                     ),
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    62
                                     MakeBooleanChecker ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    63
                                    );
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    64
  return tid;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    65
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    66
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    67
MeshWifiInterfaceMac::MeshWifiInterfaceMac ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    68
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    69
  NS_LOG_FUNCTION (this);
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
    70
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    71
  m_rxMiddle = new MacRxMiddle ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    72
  m_rxMiddle->SetForwardCallback (MakeCallback (&MeshWifiInterfaceMac::Receive, this));
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    73
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    74
  m_low = CreateObject<MacLow> ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    75
  m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle));
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    76
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    77
  m_dcfManager = new DcfManager ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    78
  m_dcfManager->SetupLowListener (m_low);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    79
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    80
  m_beaconDca = CreateObject<DcaTxop> ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    81
  m_beaconDca->SetLow (m_low);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    82
  m_beaconDca->SetMinCw (0);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    83
  m_beaconDca->SetMaxCw (0);
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
    84
  m_beaconDca->SetAifsn (1);
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    85
  m_beaconDca->SetManager (m_dcfManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    86
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    87
  m_VO = CreateObject<DcaTxop> ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    88
  m_VO->SetLow (m_low);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    89
  m_VO->SetMinCw (3);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    90
  m_VO->SetMaxCw (7);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    91
  m_VO->SetManager (m_dcfManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    92
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    93
  m_BE = CreateObject<DcaTxop> ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    94
  m_BE->SetLow (m_low);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    95
  m_BE->SetManager (m_dcfManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    96
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    97
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    98
MeshWifiInterfaceMac::~MeshWifiInterfaceMac ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    99
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   100
  NS_LOG_FUNCTION (this);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   101
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   102
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   103
//-----------------------------------------------------------------------------
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   104
// WifiMac inherited
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   105
//-----------------------------------------------------------------------------
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   106
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   107
MeshWifiInterfaceMac::SetSlot (Time slotTime)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   108
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   109
  NS_LOG_FUNCTION (this << slotTime);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   110
  m_dcfManager->SetSlot (slotTime);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   111
  m_slot = slotTime;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   112
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   113
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   114
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   115
MeshWifiInterfaceMac::SetSifs (Time sifs)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   116
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   117
  NS_LOG_FUNCTION (this << sifs);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   118
  m_dcfManager->SetSifs (sifs);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   119
  m_sifs = sifs;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   120
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   121
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   122
MeshWifiInterfaceMac::SetAckTimeout (Time ackTimeout)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   123
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   124
  m_low->SetAckTimeout (ackTimeout);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   125
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   126
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   127
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   128
MeshWifiInterfaceMac::SetCtsTimeout (Time ctsTimeout)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   129
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   130
  m_low->SetCtsTimeout (ctsTimeout);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   131
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   132
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   133
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   134
MeshWifiInterfaceMac::SetPifs (Time pifs)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   135
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   136
  NS_LOG_FUNCTION (this << pifs);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   137
  m_pifs = pifs;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   138
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   139
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   140
MeshWifiInterfaceMac::SetEifsNoDifs (Time eifsNoDifs)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   141
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   142
  NS_LOG_FUNCTION (this << eifsNoDifs);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   143
  m_dcfManager->SetEifsNoDifs (eifsNoDifs);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   144
  m_eifsNoDifs = eifsNoDifs;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   145
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   146
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   147
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   148
MeshWifiInterfaceMac::GetSlot () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   149
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   150
  return m_slot;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   151
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   152
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   153
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   154
MeshWifiInterfaceMac::GetSifs () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   155
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   156
  return m_sifs;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   157
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   158
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   159
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   160
MeshWifiInterfaceMac::GetEifsNoDifs () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   161
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   162
  return m_eifsNoDifs;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   163
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   164
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   165
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   166
MeshWifiInterfaceMac::GetAckTimeout () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   167
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   168
  return m_low->GetAckTimeout ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   169
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   170
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   171
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   172
MeshWifiInterfaceMac::GetCtsTimeout () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   173
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   174
  return m_low->GetCtsTimeout ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   175
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   176
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   177
Time
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   178
MeshWifiInterfaceMac::GetPifs () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   179
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   180
  return m_low->GetPifs ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   181
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   182
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   183
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   184
MeshWifiInterfaceMac::SetWifiPhy (Ptr<WifiPhy> phy)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   185
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   186
  NS_LOG_FUNCTION (this << phy);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   187
  m_phy = phy;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   188
  m_dcfManager->SetupPhyListener (phy);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   189
  m_low->SetPhy (phy);
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   190
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   191
  NS_LOG_DEBUG("SetWifiPhy: Can switch channel now: " << CanSwitchChannel() ); // TMP
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   192
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   193
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   194
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   195
MeshWifiInterfaceMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   196
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   197
  NS_LOG_FUNCTION (this << stationManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   198
  m_stationManager = stationManager;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   199
  m_BE->SetWifiRemoteStationManager (stationManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   200
  m_VO->SetWifiRemoteStationManager (stationManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   201
  m_beaconDca->SetWifiRemoteStationManager (stationManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   202
  m_low->SetWifiRemoteStationManager (stationManager);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   203
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   204
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   205
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   206
MeshWifiInterfaceMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   207
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   208
  NS_LOG_FUNCTION (this << packet << to << from);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   209
  ForwardDown (packet, from, to);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   210
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   211
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   212
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   213
MeshWifiInterfaceMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   214
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   215
  NS_LOG_FUNCTION (this << packet << to);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   216
  ForwardDown (packet, m_low->GetAddress (), to);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   217
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   218
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   219
bool
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   220
MeshWifiInterfaceMac::SupportsSendFrom () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   221
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   222
  return true;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   223
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   224
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   225
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   226
MeshWifiInterfaceMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   227
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   228
  NS_LOG_FUNCTION (this);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   229
  m_upCallback = upCallback;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   230
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   231
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   232
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   233
MeshWifiInterfaceMac::SetLinkUpCallback (Callback<void> linkUp)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   234
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   235
  NS_LOG_FUNCTION (this);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   236
  if (!linkUp.IsNull ())
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   237
    {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   238
      linkUp ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   239
    }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   240
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   241
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   242
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   243
MeshWifiInterfaceMac::SetLinkDownCallback (Callback<void> linkDown)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   244
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   245
  NS_LOG_FUNCTION (this);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   246
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   247
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   248
Mac48Address
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   249
MeshWifiInterfaceMac::GetAddress () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   250
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   251
  return m_address;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   252
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   253
Mac48Address
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   254
MeshWifiInterfaceMac::GetBssid () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   255
{
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   256
  return m_address;
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   257
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   258
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   259
Ssid
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   260
MeshWifiInterfaceMac::GetSsid () const
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   261
{
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   262
  return m_meshId;
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   263
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   264
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   265
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   266
MeshWifiInterfaceMac::SetAddress (Mac48Address address)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   267
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   268
  NS_LOG_FUNCTION (address);
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   269
  m_low->SetAddress (address);
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   270
  m_address = address;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   271
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   272
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   273
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   274
MeshWifiInterfaceMac::SetSsid (Ssid ssid)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   275
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   276
  NS_LOG_FUNCTION (ssid);
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   277
  m_meshId = ssid;
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   278
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   279
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   280
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   281
MeshWifiInterfaceMac::DoDispose ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   282
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   283
  NS_LOG_FUNCTION (this);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   284
  delete m_rxMiddle;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   285
  delete m_dcfManager;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   286
  //Delete smart pointers:
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   287
  m_rxMiddle = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   288
  m_low = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   289
  m_dcfManager = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   290
  m_phy = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   291
  m_BE = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   292
  m_VO = 0;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   293
  m_beaconSendEvent.Cancel ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   294
  m_beaconDca = 0;
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   295
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   296
  WifiMac::DoDispose ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   297
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   298
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   299
//-----------------------------------------------------------------------------
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   300
// Plugins
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   301
//-----------------------------------------------------------------------------
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   302
void
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   303
MeshWifiInterfaceMac::InstallPlugin ( Ptr<MeshWifiInterfaceMacPlugin> plugin)
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   304
{
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   305
  NS_LOG_FUNCTION (this);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   306
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   307
  plugin->SetParent (this);
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   308
  m_plugins.push_back (plugin);
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   309
}
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   310
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   311
//-----------------------------------------------------------------------------
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   312
// Switch channels
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   313
//-----------------------------------------------------------------------------
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   314
bool MeshWifiInterfaceMac::CanSwitchChannel () const
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   315
{
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   316
  NS_LOG_FUNCTION (this);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   317
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   318
  // now only YansWifiPhy can switch channels runtime
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   319
  if (m_phy != 0)
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   320
    {
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   321
      Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> ();
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   322
      return (phy != 0);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   323
    }
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   324
  else
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   325
    return false;
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   326
}
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   327
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   328
uint16_t MeshWifiInterfaceMac::GetFrequencyChannel () const
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   329
{
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   330
  NS_LOG_FUNCTION (this);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   331
  NS_ASSERT (m_phy != 0); // need PHY to set/get channel
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   332
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   333
  Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> ();
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   334
  if (phy != 0)
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   335
    return phy->GetFrequencyChannel ();
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   336
  else
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   337
    return 0;
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   338
}
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   339
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   340
void MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id)
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   341
{
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   342
  NS_LOG_FUNCTION (this);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   343
  NS_ASSERT (m_phy != 0); // need PHY to set/get channel
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   344
  /* TODO
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   345
   *
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   346
   * Correct channel switching is:
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   347
   *
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   348
   * 1. Interface down, e.g. to stop packets from layer 3
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   349
   * 2. Wait before all output queues will be empty
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   350
   * 3. Switch PHY channel
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   351
   * 4. Interface up
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   352
   *
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   353
   * Now we use dirty channel switch -- just change frequency
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   354
   */
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   355
  NS_ASSERT(CanSwitchChannel());
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   356
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   357
  Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> ();
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   358
  phy->SetFrequencyChannel (new_id);
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   359
  // Don't know NAV on new channel
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   360
  m_dcfManager->NotifyNavResetNow (Seconds (0));
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   361
}
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   362
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   363
//-----------------------------------------------------------------------------
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   364
// Forward frame up/down
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   365
//-----------------------------------------------------------------------------
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   366
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   367
MeshWifiInterfaceMac::ForwardUp (Ptr<Packet> packet, Mac48Address src, Mac48Address dst)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   368
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   369
  NS_LOG_FUNCTION (this << packet << src);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   370
  m_upCallback (packet, src, dst);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   371
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   372
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   373
void
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   374
MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address from, Mac48Address to)
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   375
{
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   376
  // copy packet to allow modifications
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   377
  Ptr<Packet> packet = const_packet->Copy ();
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   378
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   379
  WifiMacHeader hdr;
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   380
  hdr.SetTypeData ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   381
  hdr.SetAddr2 (GetAddress ());
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   382
  hdr.SetAddr3 (to);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   383
  hdr.SetAddr4 (from);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   384
  hdr.SetDsFrom ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   385
  hdr.SetDsTo ();
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   386
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   387
  // Address 1 is unknwon here. Routing plugin is responsible to correctly set it.
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   388
  hdr.SetAddr1 (Mac48Address ());
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   389
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   390
  // Filter packet through all installed plugins
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   391
  for (PluginList::const_iterator i = m_plugins.begin(); i != m_plugins.end(); ++i)
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   392
    {
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   393
      bool drop = ! ((*i)->UpdateOutcomingFrame(packet, hdr, from, to));
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   394
      if (drop) return; // plugin drops frame
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   395
    }
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   396
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   397
  // Assert that address1 is set. Assert will fail e.g. if there is no installed routing plugin.
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   398
  NS_ASSERT (hdr.GetAddr1() != Mac48Address() );
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   399
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   400
  // Queue frame
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   401
  WifiRemoteStation *destination = m_stationManager->Lookup (to);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   402
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   403
  if (destination->IsBrandNew ())
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   404
    {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   405
      // in adhoc mode, we assume that every destination
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   406
      // supports all the rates we support.
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   407
      for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   408
        {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   409
          destination->AddSupportedMode (m_phy->GetMode (i));
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   410
        }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   411
      destination->RecordDisassociated ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   412
    }
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   413
  m_BE->Queue (packet, hdr);
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   414
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   415
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   416
void
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   417
MeshWifiInterfaceMac::SendManagementFrame (Ptr<Packet> packet, const WifiMacHeader& hdr)
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   418
{
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   419
  m_VO->Queue (packet, hdr);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   420
}
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   421
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   422
SupportedRates
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   423
MeshWifiInterfaceMac::GetSupportedRates () const
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   424
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   425
  // set the set of supported rates and make sure that we indicate
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   426
  // the Basic Rate set in this set of supported rates.
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   427
  SupportedRates rates;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   428
  for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   429
    {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   430
      WifiMode mode = m_phy->GetMode (i);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   431
      rates.AddSupportedRate (mode.GetDataRate ());
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   432
    }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   433
  // set the basic rates
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   434
  for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   435
    {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   436
      WifiMode mode = m_stationManager->GetBasicMode (j);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   437
      rates.SetBasicRate (mode.GetDataRate ());
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   438
    }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   439
  return rates;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   440
}
4865
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   441
bool
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   442
MeshWifiInterfaceMac::CheckMeshId(Ssid meshId) const
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   443
{
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   444
  return true;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   445
}
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   446
bool
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   447
MeshWifiInterfaceMac::CheckSupportedRates(SupportedRates rates) const
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   448
{
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   449
  for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   450
  {
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   451
    WifiMode mode = m_stationManager->GetBasicMode (i);
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   452
    if (!rates.IsSupportedRate (mode.GetDataRate ()))
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   453
      return false;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   454
  }
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   455
  return true;
e331ed5d3662 Added header for peer link frame (first fields without information element)
Kirill Andreev <andreev@iitp.ru>
parents: 4857
diff changeset
   456
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   457
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   458
//-----------------------------------------------------------------------------
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   459
// Beacons
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   460
//-----------------------------------------------------------------------------
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   461
void 
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   462
MeshWifiInterfaceMac::SetRandomStartDelay (Time interval)
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   463
{
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   464
  NS_LOG_FUNCTION (this << interval);
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   465
  m_randomStart = interval;
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   466
}
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4906
diff changeset
   467
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   468
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   469
MeshWifiInterfaceMac::SetBeaconInterval (Time interval)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   470
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   471
  NS_LOG_FUNCTION (this << interval);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   472
  m_beaconInterval = interval;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   473
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   474
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   475
Time
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   476
MeshWifiInterfaceMac::GetBeaconInterval () const
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   477
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   478
  return m_beaconInterval;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   479
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   480
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   481
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   482
MeshWifiInterfaceMac::SetBeaconGeneration (bool enable)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   483
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   484
  NS_LOG_FUNCTION (this << enable);
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   485
  if (enable)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   486
    {
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   487
      // Now start sending beacons after some random delay (to avoid collisions)
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   488
      UniformVariable coefficient (0.0, m_randomStart.GetSeconds());
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   489
      Time randomStart = Seconds (coefficient.GetValue());
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   490
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   491
      m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this);
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   492
      m_tbtt = Simulator::Now() + randomStart;
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   493
    }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   494
  else
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   495
    // stop sending beacons
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   496
    m_beaconSendEvent.Cancel ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   497
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   498
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   499
bool
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   500
MeshWifiInterfaceMac::GetBeaconGeneration () const
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   501
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   502
  return m_beaconSendEvent.IsRunning ();
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   503
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   504
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   505
Time
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   506
MeshWifiInterfaceMac::GetTbtt () const
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   507
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   508
  return m_tbtt;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   509
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   510
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4855
diff changeset
   511
void MeshWifiInterfaceMac::ShiftTbtt (Time shift)
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   512
{
4857
ddfb13420455 Added new peer manager class, an old one we keep without change
Kirill Andreev <andreev@iitp.ru>
parents: 4855
diff changeset
   513
  // User of ShiftTbtt () must take care don't shift it to the past
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   514
  NS_ASSERT (GetTbtt() + shift > Simulator::Now());
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   515
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   516
  m_tbtt += shift;
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   517
  // Shift scheduled event
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   518
  Simulator::Cancel (m_beaconSendEvent);
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   519
  m_beaconSendEvent = Simulator::Schedule (GetTbtt () - Simulator::Now(), &MeshWifiInterfaceMac::SendBeacon, this);
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   520
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   521
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   522
void
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   523
MeshWifiInterfaceMac::ScheduleNextBeacon ()
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   524
{
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   525
  m_tbtt += GetBeaconInterval ();
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   526
  m_beaconSendEvent = Simulator::Schedule (GetBeaconInterval(), &MeshWifiInterfaceMac::SendBeacon, this);
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   527
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   528
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   529
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   530
MeshWifiInterfaceMac::SendBeacon ()
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   531
{
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   532
  NS_LOG_FUNCTION (this);
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   533
  NS_LOG_DEBUG (GetAddress() <<" is sending beacon");
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   534
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   535
  NS_ASSERT (! m_beaconSendEvent.IsRunning());
4855
0b5980b04249 Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
   536
  NS_ASSERT (Simulator::Now().GetMicroSeconds() == GetTbtt().GetMicroSeconds());     // assert that beacon is just on time
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   537
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   538
  // Form & send beacon
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   539
  MeshWifiBeacon beacon (GetSsid (), GetSupportedRates (), m_beaconInterval.GetMicroSeconds ());
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   540
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   541
  // Ask all plugins to add their specific information elements to beacon
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   542
  for (PluginList::const_iterator i = m_plugins.begin(); i != m_plugins.end(); ++i)
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   543
    (*i)->UpdateBeacon (beacon);
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   544
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   545
  m_beaconDca->Queue (beacon.CreatePacket(), beacon.CreateHeader(GetAddress()));
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   546
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   547
  ScheduleNextBeacon ();
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   548
}
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   549
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   550
void
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   551
MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   552
{
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   553
  // Process beacon
4877
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   554
  if((hdr->GetAddr1() != GetAddress()) && (hdr->GetAddr1() != Mac48Address::GetBroadcast()))
f08902c42733 Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents: 4876
diff changeset
   555
    return;
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   556
  if (hdr->IsBeacon ())
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   557
    {
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   558
      MgtBeaconHeader beacon_hdr;
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   559
      Mac48Address from = hdr->GetAddr2 ();
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   560
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   561
      packet->PeekHeader (beacon_hdr);
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   562
4869
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   563
      NS_LOG_DEBUG ("Beacon received from "<<hdr->GetAddr2()<<
bf6f699d4e03 Debug messages fixed
Kirill Andreev <andreev@iitp.ru>
parents: 4865
diff changeset
   564
                   " I am "<<GetAddress ()<<
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   565
                   " at "<<Simulator::Now ().GetMicroSeconds ()<<
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   566
                   " microseconds");
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   567
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   568
      // update supported rates
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   569
      if (beacon_hdr.GetSsid ().IsEqual(GetSsid()))
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   570
        {
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   571
          SupportedRates rates = beacon_hdr.GetSupportedRates ();
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   572
          WifiRemoteStation * peerSta = m_stationManager->Lookup (hdr->GetAddr2 ());
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   573
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   574
          for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   575
          {
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   576
            WifiMode mode = m_phy->GetMode (i);
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   577
            if (rates.IsSupportedRate (mode.GetDataRate ()))
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   578
              {
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   579
                peerSta->AddSupportedMode (mode);
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   580
                if (rates.IsBasicRate (mode.GetDataRate ()))
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   581
                  m_stationManager->AddBasicMode (mode);
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   582
              }
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   583
          }
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   584
        }
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   585
    }
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   586
  // Filter frame through all installed plugins
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   587
  for (PluginList::iterator i = m_plugins.begin (); i != m_plugins.end(); ++i)
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   588
    {
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   589
      bool drop = ! ((*i)->Receive(packet, *hdr));
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   590
      if (drop) return; // plugin drops frame
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   591
    }
4934
345b49df838b Frequency channel switch on channel, PHY and MAC levels
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
   592
4844
3c38e23fa821 Basic MAC plugins functionality implemented
Pavel Boyko <boyko@iitp.ru>
parents: 4843
diff changeset
   593
  // Forward data up
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   594
  if (hdr->IsData ())
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4844
diff changeset
   595
      ForwardUp (packet, hdr->GetAddr4(), hdr->GetAddr3());
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   596
}
4944
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4934
diff changeset
   597
uint32_t
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4934
diff changeset
   598
MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress)
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4934
diff changeset
   599
{
4946
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   600
  uint32_t metric = 1;
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   601
  if(!m_linkMetricCallback.IsNull ())
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   602
    metric = m_linkMetricCallback(peerAddress, this);
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   603
  return metric;
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   604
}
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   605
void
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   606
MeshWifiInterfaceMac::SetLinkMetricCallback (Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > cb)
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   607
{
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   608
  m_linkMetricCallback = cb;
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   609
}
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   610
Ptr<WifiRemoteStationManager>
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   611
MeshWifiInterfaceMac::GetStationManager()
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   612
{
f97e16db1d79 Added airtime link metric. packet error rate is not done yet
Kirill Andreev <andreev@iitp.ru>
parents: 4944
diff changeset
   613
  return m_stationManager;
4944
779b641cff5a Unicast chain instead of broadcast data frame added. Metric
Kirill Andreev <andreev@iitp.ru>
parents: 4934
diff changeset
   614
}
4843
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   615
} // namespace ns3
f65f22ef327e MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
   616