Last active
December 22, 2015 14:08
-
-
Save piotrjurkiewicz/6483675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ./src/wifi/model/edca-txop-n.cc 2013-05-12 18:50:16.000000000 +0200 | |
+++ ./src/wifi/model/edca-txop-n.cc 2013-06-01 01:53:32.137853867 +0200 | |
@@ -835,10 +835,14 @@ EdcaTxopN::MapSrcAddressForAggregation ( | |
{ | |
retval = hdr.GetAddr2 (); | |
} | |
- else | |
+ else if (m_typeOfStation == AP) | |
{ | |
retval = hdr.GetAddr3 (); | |
} | |
+ else | |
+ { | |
+ retval = hdr.GetAddr4 (); | |
+ } | |
return retval; | |
} | |
--- ./src/wifi/model/edca-txop-n.h 2013-05-12 18:50:16.000000000 +0200 | |
+++ ./src/wifi/model/edca-txop-n.h 2013-06-01 02:03:45.101869057 +0200 | |
@@ -58,7 +58,8 @@ enum TypeOfStation | |
STA, | |
AP, | |
ADHOC_STA, | |
- MESH | |
+ MESH, | |
+ WDS | |
}; | |
--- ./src/wifi/model/wds-wifi-mac.cc 1970-01-01 01:00:00.000000000 +0100 | |
+++ ./src/wifi/model/wds-wifi-mac.cc 2013-07-17 06:46:20.403606356 +0200 | |
@@ -0,0 +1,227 @@ | |
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
+/* | |
+ * Copyright (c) 2006, 2009 INRIA | |
+ * Copyright (c) 2009 MIRKO BANCHI | |
+ * Copyright (c) 2013 PIOTR JURKIEWICZ | |
+ * | |
+ * 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: Mathieu Lacage <[email protected]> | |
+ * Author: Mirko Banchi <[email protected]> | |
+ * Author: Piotr Jurkiewicz <[email protected]> | |
+ */ | |
+#include "wds-wifi-mac.h" | |
+ | |
+#include "ns3/pointer.h" | |
+#include "ns3/log.h" | |
+#include "ns3/string.h" | |
+#include "ns3/boolean.h" | |
+#include "ns3/trace-source-accessor.h" | |
+ | |
+#include "qos-tag.h" | |
+#include "mac-low.h" | |
+#include "dcf-manager.h" | |
+#include "mac-rx-middle.h" | |
+#include "mac-tx-middle.h" | |
+#include "msdu-aggregator.h" | |
+#include "amsdu-subframe-header.h" | |
+#include "mgt-headers.h" | |
+ | |
+NS_LOG_COMPONENT_DEFINE ("WDSWifiMac"); | |
+ | |
+namespace ns3 { | |
+ | |
+NS_OBJECT_ENSURE_REGISTERED (WDSWifiMac); | |
+ | |
+TypeId | |
+WDSWifiMac::GetTypeId (void) | |
+{ | |
+ static TypeId tid = TypeId ("ns3::WDSWifiMac") | |
+ .SetParent<RegularWifiMac> () | |
+ .AddConstructor<WDSWifiMac> () | |
+ .AddAttribute ("ReceiverAddress", "The MAC address of the receiver", | |
+ Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), | |
+ MakeMac48AddressAccessor (&WDSWifiMac::m_ra), | |
+ MakeMac48AddressChecker ()) | |
+ ; | |
+ return tid; | |
+} | |
+ | |
+WDSWifiMac::WDSWifiMac () | |
+{ | |
+ NS_LOG_FUNCTION (this); | |
+ | |
+ // Let the lower layers know that we are acting in an IBSS | |
+ SetTypeOfStation (WDS); | |
+} | |
+ | |
+WDSWifiMac::~WDSWifiMac () | |
+{ | |
+ NS_LOG_FUNCTION (this); | |
+} | |
+ | |
+void | |
+WDSWifiMac::SetAddress (Mac48Address address) | |
+{ | |
+ NS_LOG_FUNCTION (this << address); | |
+ // In an IBSS, the BSSID is supposed to be generated per Section | |
+ // 11.1.3 of IEEE 802.11. We don't currently do this - instead we | |
+ // make an IBSS STA a bit like an AP, with the BSSID for frames | |
+ // transmitted by each STA set to that STA's address. | |
+ // | |
+ // This is why we're overriding this method. | |
+ RegularWifiMac::SetAddress (address); | |
+ RegularWifiMac::SetBssid (address); | |
+} | |
+ | |
+void | |
+WDSWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to) | |
+{ | |
+ NS_LOG_FUNCTION (this << packet << to); | |
+ // We're sending this packet with a from address that is our own. We | |
+ // get that address from the lower MAC and make use of the | |
+ // from-spoofing Enqueue() method to avoid duplicated code. | |
+ Enqueue (packet, to, m_low->GetAddress ()); | |
+} | |
+ | |
+void | |
+WDSWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from) | |
+{ | |
+ NS_LOG_FUNCTION (this << packet << to << from); | |
+ if (m_stationManager->IsBrandNew (m_ra)) | |
+ { | |
+ // In ad hoc mode, we assume that every destination supports all | |
+ // the rates we support. | |
+ for (uint32_t i = 0; i < m_phy->GetNModes (); i++) | |
+ { | |
+ m_stationManager->AddSupportedMode (m_ra, m_phy->GetMode (i)); | |
+ } | |
+ m_stationManager->RecordDisassociated (m_ra); | |
+ } | |
+ | |
+ WifiMacHeader hdr; | |
+ | |
+ // If we are not a QoS STA then we definitely want to use AC_BE to | |
+ // transmit the packet. A TID of zero will map to AC_BE (through \c | |
+ // QosUtilsMapTidToAc()), so we use that as our default here. | |
+ uint8_t tid = 0; | |
+ | |
+ // For now, a STA that supports QoS does not support non-QoS | |
+ // associations, and vice versa. In future the STA model should fall | |
+ // back to non-QoS if talking to a peer that is also non-QoS. At | |
+ // that point there will need to be per-station QoS state maintained | |
+ // by the association state machine, and consulted here. | |
+ if (m_qosSupported) | |
+ { | |
+ hdr.SetType (WIFI_MAC_QOSDATA); | |
+ hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); | |
+ hdr.SetQosNoEosp (); | |
+ hdr.SetQosNoAmsdu (); | |
+ // Transmission of multiple frames in the same TXOP is not | |
+ // supported for now | |
+ hdr.SetQosTxopLimit (0); | |
+ | |
+ // Fill in the QoS control field in the MAC header | |
+ tid = QosUtilsGetTidForPacket (packet); | |
+ // Any value greater than 7 is invalid and likely indicates that | |
+ // the packet had no QoS tag, so we revert to zero, which'll | |
+ // mean that AC_BE is used. | |
+ if (tid >= 7) | |
+ { | |
+ tid = 0; | |
+ } | |
+ hdr.SetQosTid (tid); | |
+ } | |
+ else | |
+ { | |
+ hdr.SetTypeData (); | |
+ } | |
+ | |
+ | |
+ hdr.SetAddr1 (m_ra); | |
+ hdr.SetAddr2 (m_low->GetAddress ()); | |
+ | |
+ hdr.SetAddr3 (to); | |
+ hdr.SetAddr4 (from); | |
+ | |
+ | |
+ hdr.SetDsFrom (); | |
+ hdr.SetDsTo (); | |
+ | |
+ if (m_qosSupported) | |
+ { | |
+ // Sanity check that the TID is valid | |
+ NS_ASSERT (tid < 8); | |
+ m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr); | |
+ } | |
+ else | |
+ { | |
+ m_dca->Queue (packet, hdr); | |
+ } | |
+} | |
+ | |
+bool | |
+WDSWifiMac::SupportsSendFrom (void) const | |
+{ | |
+ NS_LOG_FUNCTION (this); | |
+ return true; | |
+} | |
+ | |
+void | |
+WDSWifiMac::SetReceiverAddress (Mac48Address ra) | |
+{ | |
+ NS_LOG_FUNCTION (this << ra); | |
+ m_ra = ra; | |
+} | |
+ | |
+void | |
+WDSWifiMac::SetLinkUpCallback (Callback<void> linkUp) | |
+{ | |
+ NS_LOG_FUNCTION (this << &linkUp); | |
+ RegularWifiMac::SetLinkUpCallback (linkUp); | |
+ | |
+ // The approach taken here is that, from the point of view of a STA | |
+ // in IBSS mode, the link is always up, so we immediately invoke the | |
+ // callback if one is set | |
+ linkUp (); | |
+} | |
+ | |
+void | |
+WDSWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) | |
+{ | |
+ NS_LOG_FUNCTION (this << packet << hdr); | |
+ NS_ASSERT (!hdr->IsCtl ()); | |
+ Mac48Address from = hdr->GetAddr4 (); | |
+ Mac48Address to = hdr->GetAddr3 (); | |
+ if (hdr->IsData ()) | |
+ { | |
+ if (hdr->IsQosData () && hdr->IsQosAmsdu ()) | |
+ { | |
+ NS_LOG_DEBUG ("Received A-MSDU from" << from); | |
+ DeaggregateAmsduAndForward (packet, hdr); | |
+ } | |
+ else | |
+ { | |
+ ForwardUp (packet, from, to); | |
+ } | |
+ return; | |
+ } | |
+ | |
+ // Invoke the receive handler of our parent class to deal with any | |
+ // other frames. Specifically, this will handle Block Ack-related | |
+ // Management Action frames. | |
+ RegularWifiMac::Receive (packet, hdr); | |
+} | |
+ | |
+} // namespace ns3 | |
--- ./src/wifi/model/wds-wifi-mac.h 1970-01-01 01:00:00.000000000 +0100 | |
+++ ./src/wifi/model/wds-wifi-mac.h 2013-06-01 01:36:58.673829245 +0200 | |
@@ -0,0 +1,83 @@ | |
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
+/* | |
+ * Copyright (c) 2006, 2009 INRIA | |
+ * Copyright (c) 2009 MIRKO BANCHI | |
+ * Copyright (c) 2013 PIOTR JURKIEWICZ | |
+ * | |
+ * 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: Mathieu Lacage <[email protected]> | |
+ * Author: Mirko Banchi <[email protected]> | |
+ * Author: Piotr Jurkiewicz <[email protected]> | |
+ */ | |
+#ifndef WDS_WIFI_MAC_H | |
+#define WDS_WIFI_MAC_H | |
+ | |
+#include "regular-wifi-mac.h" | |
+ | |
+#include "amsdu-subframe-header.h" | |
+ | |
+namespace ns3 { | |
+ | |
+/** | |
+ * \ingroup wifi | |
+ * | |
+ * | |
+ */ | |
+class WDSWifiMac : public RegularWifiMac | |
+{ | |
+public: | |
+ static TypeId GetTypeId (void); | |
+ | |
+ WDSWifiMac (); | |
+ virtual ~WDSWifiMac (); | |
+ | |
+ /** | |
+ * \param address the current address of this MAC layer. | |
+ */ | |
+ virtual void SetAddress (Mac48Address address); | |
+ | |
+ /** | |
+ * \param linkUp the callback to invoke when the link becomes up. | |
+ */ | |
+ virtual void SetLinkUpCallback (Callback<void> linkUp); | |
+ | |
+ /** | |
+ * \param packet the packet to send. | |
+ * \param to the address to which the packet should be sent. | |
+ * | |
+ * The packet should be enqueued in a tx queue, and should be | |
+ * dequeued as soon as the channel access function determines that | |
+ * access is granted to this MAC. | |
+ */ | |
+ | |
+ virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to); | |
+ virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); | |
+ | |
+ virtual bool SupportsSendFrom (void) const; | |
+ | |
+ void SetReceiverAddress(Mac48Address ra); | |
+ | |
+protected: | |
+ | |
+ Mac48Address m_ra; | |
+ | |
+ | |
+private: | |
+ virtual void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr); | |
+}; | |
+ | |
+} // namespace ns3 | |
+ | |
+#endif /* WDS_WIFI_MAC_H */ | |
--- ./src/wifi/wscript 2013-05-12 18:50:16.000000000 +0200 | |
+++ ./src/wifi/wscript 2013-06-01 00:09:32.665699239 +0200 | |
@@ -36,6 +36,7 @@ def build(bld): | |
'model/ap-wifi-mac.cc', | |
'model/sta-wifi-mac.cc', | |
'model/adhoc-wifi-mac.cc', | |
+ 'model/wds-wifi-mac.cc', | |
'model/wifi-net-device.cc', | |
'model/arf-wifi-manager.cc', | |
'model/aarf-wifi-manager.cc', | |
@@ -95,6 +96,7 @@ def build(bld): | |
'model/ap-wifi-mac.h', | |
'model/sta-wifi-mac.h', | |
'model/adhoc-wifi-mac.h', | |
+ 'model/wds-wifi-mac.h', | |
'model/arf-wifi-manager.h', | |
'model/aarf-wifi-manager.h', | |
'model/ideal-wifi-manager.h', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment