Mesh ID is made separately from SSID

This commit is contained in:
Kirill Andreev
2009-05-22 17:27:10 +04:00
parent 959653b5fa
commit ede41dc54d
13 changed files with 271 additions and 61 deletions

View File

@@ -138,7 +138,7 @@ MeshTest::CreateNodes ()
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (nodes);
if (pcap)
wifiPhy.EnablePcapAll (std::string ("mp-") + mesh.GetSsid ().PeekString ());
wifiPhy.EnablePcapAll (std::string ("mp-"));
}
void
MeshTest::InstallInternetStack ()

View File

@@ -34,23 +34,10 @@ namespace ns3 {
namespace dot11s {
MeshWifiHelper::MeshWifiHelper () :
m_ssid("mesh"),
m_randomStartDelay (Seconds (0)),
m_spreadInterfaceChannels (false)
{
}
void
MeshWifiHelper::SetSsid (Ssid const & s)
{
m_ssid = s;
}
Ssid MeshWifiHelper::GetSsid () const
{
return m_ssid;
}
void
MeshWifiHelper::SetRandomStartDelay (Time t)
{
@@ -71,7 +58,7 @@ MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node)
// Creating MAC for this interface
Ptr<MeshWifiInterfaceMac> mac = CreateObject<MeshWifiInterfaceMac> ();
mac->SetSsid (m_ssid);
mac->SetSsid (Ssid ());
if (m_randomStartDelay > Seconds (0))
mac->SetRandomStartDelay (m_randomStartDelay);
Ptr<WifiRemoteStationManager> manager = CreateObject<AarfWifiManager> ();
@@ -130,6 +117,7 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, std::
// Install 802.11s protocols
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
pmp->SetMeshId("mesh",4);
bool install_ok = pmp->Install (mp);
NS_ASSERT (install_ok);

View File

@@ -24,10 +24,10 @@
#define _MESHWIFIHELPER_H
#include "ns3/wifi-helper.h"
#include "ns3/ssid.h"
#include "ns3/nstime.h"
#include "ns3/peer-management-protocol.h"
#include "ns3/hwmp-protocol.h"
#include "ie-dot11s-id.h"
namespace ns3 {
namespace dot11s {
@@ -43,10 +43,6 @@ class MeshWifiHelper
{
public:
MeshWifiHelper ();
/// Set mesh SSID
void SetSsid (const Ssid &);
/// Get mesh SSID
Ssid GetSsid () const;
/// Set maximum random start delay
void SetRandomStartDelay (Time delay);
/**
@@ -82,7 +78,6 @@ public:
static void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
static void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
private:
Ssid m_ssid;
Time m_randomStartDelay;
bool m_spreadInterfaceChannels;

View File

@@ -0,0 +1,157 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Kirill Andreev <andreev@iitp.ru>
*/
#include "ie-dot11s-id.h"
#include "ns3/assert.h"
namespace ns3 {
namespace dot11s {
IeMeshId::IeMeshId ()
{
for (uint8_t i = 0; i < 32; i++)
{
m_meshId[i] = 0;
}
}
IeMeshId::IeMeshId (char const meshId[32], uint8_t length)
{
NS_ASSERT (length <= 32);
uint8_t len = 0;
while (len < length)
{
m_meshId[len] = meshId[len];
len++;
}
while (len < 32)
{
m_meshId[len] = 0;
len++;
}
}
bool
IeMeshId::IsEqual (IeMeshId const &o) const
{
uint8_t i = 0;
while (i < 32 &&
m_meshId[i] == o.m_meshId[i] &&
m_meshId[i] != 0)
{
i++;
}
if (m_meshId[i] != o.m_meshId[i])
{
return false;
}
return true;
}
bool
IeMeshId::IsBroadcast (void) const
{
if (m_meshId[0] == 0)
{
return true;
}
return false;
}
char *
IeMeshId::PeekString (void) const
{
return (char *)m_meshId;
}
uint8_t
IeMeshId::GetInformationSize (void) const
{
uint8_t size = 0;
while (m_meshId[size] != 0 && size < 32)
{
size++;
}
NS_ASSERT (size <= 32);
return size;
}
void
IeMeshId::SerializeInformation (Buffer::Iterator i) const
{
uint8_t size = 0;
while (m_meshId[size] != 0 && size < 32)
{
i.WriteU8 (m_meshId [size]);
size ++;
}
}
uint8_t
IeMeshId::DeserializeInformation (Buffer::Iterator start, uint8_t length)
{
Buffer::Iterator i = start;
NS_ASSERT (length <= 32);
i.Read (m_meshId, length);
m_meshId[length] = 0;
return i.GetDistanceFrom(start);
}
void
IeMeshId::PrintInformation (std::ostream& os) const
{
//TODO
}
bool operator== (const IeMeshId & a, const IeMeshId & b)
{
bool result (true);
uint8_t size = 0;
while(size < 32)
{
result = result && (a.m_meshId[size] == b.m_meshId[size]);
if(a.m_meshId[size] == 0)
return result;
size ++;
}
return result;
};
std::ostream &
operator << (std::ostream &os, const IeMeshId &meshId)
{
os << meshId.PeekString ();
return os;
}
#ifdef RUN_SELF_TESTS
/// Built-in self test for IeMeshId
struct IeMeshIdBist : public IeTest
{
IeMeshIdBist () : IeTest ("Mesh/802.11s/IE/MESH_ID") {}
virtual bool RunTests();
};
/// Test instance
static IeMeshIdBist g_IeMeshIdBist;
bool IeMeshIdBist::RunTests ()
{
bool result(true);
// create test information element
IeMeshId a("qwerty",6);
result = result && TestRoundtripSerialization (a);
return result;
}
#endif // RUN_SELF_TESTS
} //namespace dot11s
} // namespace ns3

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Kirill Andreev <andreev@iitp.ru>
*/
#ifndef MESH_ID_H
#define MESH_ID_H
#include <stdint.h>
#include "ns3/buffer.h"
#include "ns3/wifi-information-element.h"
namespace ns3 {
namespace dot11s {
/**
* \brief a IEEE 802.11s Mesh ID 7.3.287 of 802.11s draft 3.0
*
*/
class IeMeshId : public WifiInformationElement
{
public:
// broadcast meshId
IeMeshId ();
//IeMeshId (char const meshId[32]);
IeMeshId (char const meshId[32], uint8_t length);
bool IsEqual (IeMeshId const &o) const;
bool IsBroadcast (void) const;
uint32_t GetLength (void) const;
char *PeekString (void) const;
private:
WifiElementId ElementId () const{
return IE11S_MESH_ID;
};
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
void PrintInformation (std::ostream& os) const;
uint8_t GetInformationSize () const;
private:
uint8_t m_meshId[33];
friend bool operator== (const IeMeshId & a, const IeMeshId & b);
};
std::ostream &operator << (std::ostream &os, const IeMeshId &meshId);
/**
* \class ns3::IeMeshIdValue
* \brief hold objects of type ns3::IeMeshId
*/
ATTRIBUTE_HELPER_HEADER (IeMeshId);
} //namespace dot11s
} // namespace ns3
#endif /* MESH_ID_H */

View File

@@ -33,7 +33,7 @@ PeerLinkFrameStart::PeerLinkFrameStart ():
m_capability (0),
m_aid (0),
m_rates (SupportedRates()),
m_meshId (Ssid()),
m_meshId (IeMeshId()),
m_config(IeConfiguration ()),
m_reasonCode ((uint16_t)REASON11S_RESERVED)
{
@@ -61,7 +61,6 @@ PeerLinkFrameStart::SetPlinkFrameStart(PeerLinkFrameStart::PlinkFrameStartFields
else
m_reasonCode = fields.reasonCode;
}
PeerLinkFrameStart::PlinkFrameStartFields
PeerLinkFrameStart::GetFields ()
{
@@ -76,18 +75,6 @@ PeerLinkFrameStart::GetFields ()
retval.reasonCode = m_reasonCode;
return retval;
}
bool
PeerLinkFrameStart::CheckPlinkFrameStart(Ptr<MeshWifiInterfaceMac> mac)
{
bool retval;
retval = mac->CheckSupportedRates(m_rates);
if(! retval)
return retval;
retval = mac->CheckMeshId(m_meshId);
return true;
}
TypeId
PeerLinkFrameStart::GetTypeId ()
{
@@ -98,7 +85,6 @@ PeerLinkFrameStart::GetTypeId ()
;
return tid;
}
TypeId
PeerLinkFrameStart::GetInstanceTypeId () const
{
@@ -115,7 +101,6 @@ PeerLinkFrameStart::Print (std::ostream &os) const
<< "\nconfiguration = " << m_config
<< "\nreason code = " << m_reasonCode;
}
uint32_t
PeerLinkFrameStart::GetSerializedSize () const
{
@@ -135,7 +120,6 @@ PeerLinkFrameStart::GetSerializedSize () const
size += 2; //reasonCode
return size;
}
void
PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
{
@@ -150,7 +134,10 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
i = m_rates.Serialize (i);
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CONFIRM) != m_subtype)
i = m_meshId.Serialize (i);
{
m_meshId.Serialize (i);
i.Next(m_meshId.GetSerializedSize ());
}
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
m_config.Serialize (i);
@@ -159,7 +146,6 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
else
i.WriteHtolsbU16(m_reasonCode);
}
uint32_t
PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
{
@@ -174,7 +160,10 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
i = m_rates.Deserialize (i);
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CONFIRM) != m_subtype)
i = m_meshId.Deserialize (i);
{
m_meshId.Deserialize (i);
i.Next(m_meshId.GetSerializedSize ());
}
if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
{
m_config.Deserialize (i);
@@ -196,14 +185,12 @@ bool operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b)
);
}
#ifdef RUN_SELF_TESTS
/// Built-in self test for PeerLinkFrameStart
struct PeerLinkFrameStartBist : public Test
{
PeerLinkFrameStartBist () : Test ("Mesh/802.11s/IE/PeerLinkFrameStart") {}
virtual bool RunTests();
};
/// Test instance
static PeerLinkFrameStartBist g_PeerLinkFrameStartBist;
@@ -216,7 +203,7 @@ bool PeerLinkFrameStartBist::RunTests ()
fields.subtype = (uint8_t)(WifiMeshActionHeader::PEER_LINK_OPEN);
fields.aid = 101;
fields.reasonCode = 12;
fields.meshId = Ssid("qwertyuiop");
fields.meshId = IeMeshId("qwertyuiop", 10);
a.SetPlinkFrameStart(fields);
Ptr<Packet> packet = Create<Packet> ();
packet->AddHeader (a);
@@ -231,7 +218,7 @@ bool PeerLinkFrameStartBist::RunTests ()
fields.subtype = (uint8_t)(WifiMeshActionHeader::PEER_LINK_CONFIRM);
fields.aid = 1234;
fields.reasonCode = 12;
fields.meshId = Ssid("qwerty");
fields.meshId = IeMeshId("qwerty", 6);
a.SetPlinkFrameStart(fields);
Ptr<Packet> packet = Create<Packet> ();
packet->AddHeader (a);
@@ -245,7 +232,7 @@ bool PeerLinkFrameStartBist::RunTests ()
PeerLinkFrameStart::PlinkFrameStartFields fields;
fields.subtype = (uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE);
fields.aid = 10;
fields.meshId = Ssid("qqq");
fields.meshId = IeMeshId("qqq", 3);
fields.reasonCode = 12;
a.SetPlinkFrameStart(fields);
Ptr<Packet> packet = Create<Packet> ();

View File

@@ -22,10 +22,10 @@
#define PEER_LINK_FRAME_START_H
#include "ns3/header.h"
#include "ns3/supported-rates.h"
#include "ns3/ssid.h"
#include "dot11s-mac-header.h"
#include "ie-dot11s-configuration.h"
#include "ie-dot11s-peering-protocol.h"
#include "ie-dot11s-id.h"
namespace ns3 {
class MeshWifiInterfaceMac;
namespace dot11s {
@@ -38,7 +38,7 @@ namespace dot11s {
* - Subtype field
* - Association ID field
* - Supported rates
* - SSID of mesh
* - Mesh ID of mesh
*/
class PeerLinkFrameStart : public Header
{
@@ -52,7 +52,7 @@ public:
uint16_t capability; //open and confirm
uint16_t aid; //confirm only
SupportedRates rates; //open and confirm
Ssid meshId; //open and close
IeMeshId meshId; //open and close
IeConfiguration config; //open and confirm
uint16_t reasonCode; //close only
};
@@ -61,7 +61,6 @@ public:
void SetPlinkFrameSubtype(uint8_t subtype);
void SetPlinkFrameStart(PlinkFrameStartFields);
PlinkFrameStartFields GetFields ();
bool CheckPlinkFrameStart(Ptr<MeshWifiInterfaceMac> mac);
/** \name Inherited from header:
* \{
*/
@@ -80,7 +79,7 @@ private:
uint16_t m_capability;
uint16_t m_aid;
SupportedRates m_rates;
Ssid m_meshId;
IeMeshId m_meshId;
IeConfiguration m_config;
uint16_t m_reasonCode;

View File

@@ -54,11 +54,16 @@ PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & h
if(header.IsBeacon())
{
IeBeaconTiming beaconTiming;
IeMeshId meshId;
Ptr<Packet> myBeacon = packet->Copy();
MgtBeaconHeader beacon_hdr;
myBeacon->RemoveHeader(beacon_hdr);
meshId.FindFirst(myBeacon);
bool meshBeacon = false;
if(beaconTiming.FindFirst(myBeacon))
if (
(beaconTiming.FindFirst(myBeacon)) &&
(m_protocol->GetMeshId ()->IsEqual(meshId))
)
meshBeacon = true;
m_protocol->UpdatePeerBeaconTiming(
m_ifIndex,
@@ -103,7 +108,7 @@ PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & h
}
if (
(actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CONFIRM) &&
!fields.meshId.IsEqual(m_parent->GetSsid())
!fields.meshId.IsEqual(*(m_protocol->GetMeshId()))
)
{
m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
@@ -165,6 +170,7 @@ PeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
{
Ptr<IeBeaconTiming> beaconTiming = m_protocol->GetBeaconTimingElement(m_ifIndex);
beacon.AddInformationElement(beaconTiming);
beacon.AddInformationElement(m_protocol->GetMeshId ());
}
void
@@ -182,7 +188,7 @@ PeerManagerMacPlugin::SendPeerLinkManagementFrame(
packet->AddHeader (peerElement);
PeerLinkFrameStart::PlinkFrameStartFields fields;
fields.rates = m_parent->GetSupportedRates ();
fields.meshId = m_parent->GetSsid ();
fields.meshId = *(m_protocol->GetMeshId ());
fields.config = meshConfig;
PeerLinkFrameStart plinkFrame;
//Create an 802.11 frame header:

View File

@@ -472,6 +472,16 @@ PeerManagementProtocol::GetNumberOfLinks ()
{
return m_numberOfActivePeers;
}
Ptr<IeMeshId>
PeerManagementProtocol::GetMeshId () const
{
return m_meshId;
}
void
PeerManagementProtocol::SetMeshId(char const meshId[32], uint8_t length)
{
m_meshId = Create<IeMeshId> (meshId, length);
}
Mac48Address
PeerManagementProtocol::GetAddress ()
{

View File

@@ -29,6 +29,7 @@
#include "ns3/nstime.h"
#include "ie-dot11s-beacon-timing.h"
#include "ie-dot11s-peer-management.h"
#include "ie-dot11s-id.h"
#include <map>
namespace ns3 {
@@ -136,6 +137,8 @@ public:
Mac48Address GetAddress ();
///\Needed to fill mesh configuration
uint8_t GetNumberOfLinks ();
void SetMeshId (char const meshId[32], uint8_t length);
Ptr<IeMeshId> GetMeshId() const;
///\brief: Report statistics
void Report (std::ostream &) const;
void ResetStats ();
@@ -192,6 +195,7 @@ private:
private:
PeerManagerPluginMap m_plugins;
Mac48Address m_address;
Ptr<IeMeshId> m_meshId;
/**
* \name Information related to beacons:
* \{

View File

@@ -5,6 +5,7 @@ def build(bld):
obj.source = [
'ie-dot11s-beacon-timing.cc',
'ie-dot11s-configuration.cc',
'ie-dot11s-id.cc',
'ie-dot11s-peer-management.cc',
'ie-dot11s-preq.cc',
'ie-dot11s-prep.cc',

View File

@@ -449,11 +449,6 @@ MeshWifiInterfaceMac::GetSupportedRates () const
return rates;
}
bool
MeshWifiInterfaceMac::CheckMeshId(Ssid meshId) const
{
return true;
}
bool
MeshWifiInterfaceMac::CheckSupportedRates(SupportedRates rates) const
{
for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)

View File

@@ -145,8 +145,6 @@ public:
/// To be used by plugins sending management frames.
void SendManagementFrame(Ptr<Packet> frame, const WifiMacHeader& hdr);
/// \return true if meshId is correct Ssid
bool CheckMeshId(Ssid meshId) const;
/// \return true if rates are supported
bool CheckSupportedRates(SupportedRates rates) const;
/// \return list of supported bitrates