Peer link frame - done

This commit is contained in:
Kirill Andreev
2009-04-22 14:00:09 +04:00
parent 9e71015a84
commit a5b6dd2704
6 changed files with 133 additions and 11 deletions

View File

@@ -0,0 +1,67 @@
/* -*- 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
*
* Authors: Kirill Andreev <andreev@iitp.ru>
*/
#include "ie-dot11s-peering-protocol.h"
namespace ns3 {
namespace dot11s {
TypeId
IePeeringProtocol::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::dot11s::IePeeringProtocol")
.SetParent<WifiInformationElement> ();
return tid;
}
TypeId
IePeeringProtocol::GetInstanceTypeId () const
{
return GetTypeId ();
}
uint8_t
IePeeringProtocol::GetInformationSize () const
{
return 1;
}
IePeeringProtocol::IePeeringProtocol ():
m_protocol(0)
{
}
void
IePeeringProtocol::SerializeInformation (Buffer::Iterator i) const
{
i.WriteU8 (m_protocol);
}
uint8_t
IePeeringProtocol::DeserializeInformation (Buffer::Iterator i, uint8_t length)
{
Buffer::Iterator start = i;
m_protocol = i.ReadU8 ();
return i.GetDistanceFrom (start);
}
void
IePeeringProtocol::PrintInformation (std::ostream& os) const
{
//TODO: print
}
} // namespace dot11s
} //namespace ns3

View File

@@ -0,0 +1,50 @@
/* -*- 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
*
* Authors: Kirill Andreev <andreev@iitp.ru>
*/
#ifndef MESH_PERING_PROTOCOL_H
#define MESH_PEERING_PROTOCOL_H
#include "ns3/wifi-information-element.h"
namespace ns3 {
namespace dot11s {
class IePeeringProtocol : public WifiInformationElement
{
public:
static TypeId GetTypeId ();
TypeId GetInstanceTypeId () const;
IePeeringProtocol ();
private:
WifiElementId ElementId () const
{
return IE11S_PEERING_PROTOCOL;
}
uint8_t GetInformationSize () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
void PrintInformation (std::ostream& os) const;
private:
uint8_t m_protocol;
};
} // namespace dot11s
} //namespace ns3
#endif

View File

@@ -48,7 +48,7 @@ void
PeerLinkFrameStart::SetPlinkFrameStart(PeerLinkFrameStart::PlinkFrameStartFields fields)
{
m_subtype = fields.subtype;
//TODO: protocol version
m_protocol = fields.protocol;
if(m_subtype != (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE))
m_capability = fields.capability;
if(m_subtype == (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM))
@@ -142,7 +142,8 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
NS_ASSERT(m_subtype < 3);
i.Next(3);
m_protocol.Serialize (i);
i.Next (m_protocol.GetSerializedSize ());
if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype)
i.WriteHtonU16(m_capability);
if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype)
@@ -163,7 +164,8 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
NS_ASSERT(m_subtype < 3);
i.Next(3); //peering protocol:
m_protocol.Deserialize (i);
i.Next (m_protocol.GetSerializedSize ());
if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype)
m_capability = i.ReadNtohU16();
if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype)

View File

@@ -25,6 +25,7 @@
#include "ns3/ssid.h"
#include "dot11s-mac-header.h"
#include "ie-dot11s-configuration.h"
#include "ie-dot11s-peering-protocol.h"
namespace ns3 {
class MeshWifiInterfaceMac;
namespace dot11s {
@@ -47,13 +48,13 @@ public:
struct PlinkFrameStartFields
{
uint8_t subtype;
// //Peering protocol version - in all subtypes - 3 octets
uint16_t capability; //open and confirm
uint16_t aid; //confirm only
SupportedRates rates; //open and confirm
Ssid meshId; //open and confirm
IeConfiguration config; //open and confirm
uint16_t reasonCode; //close only
IePeeringProtocol protocol; //Peering protocol version - in all subtypes - 3 octets
uint16_t capability; //open and confirm
uint16_t aid; //confirm only
SupportedRates rates; //open and confirm
Ssid meshId; //open and confirm
IeConfiguration config; //open and confirm
uint16_t reasonCode; //close only
};
///\attention: must be set before deserialize, before only multihop
//action header knows about subtype
@@ -75,6 +76,7 @@ public:
*/
private:
uint8_t m_subtype;
IePeeringProtocol m_protocol;
uint16_t m_capability;
uint16_t m_aid;
SupportedRates m_rates;

View File

@@ -10,6 +10,7 @@ def build(bld):
'ie-dot11s-prep.cc',
'ie-dot11s-perr.cc',
'ie-dot11s-rann.cc',
'ie-dot11s-peering-protocol.cc',
'dot11s-mac-header.cc',
'peer-link-frame.cc',
'peer-link.cc',

View File

@@ -56,7 +56,7 @@ enum WifiElementId {
IE11S_PROXY_UPDATE_CONFIRMATION = 39,
IE11S_MSCIE = 40,
IE11S_MSAIE = 41,
IE11S_PEERING_PROTOCOL = 42,
/* this ID are compatible with open80211s implementation */
IE11S_MESH_CONFIGURATION = 51,
IE11S_MESH_ID = 52,