diff --git a/src/devices/wifi/wifi-mac-trailer.cc b/src/devices/wifi/wifi-mac-trailer.cc index f6d11915a..9b535d3c9 100644 --- a/src/devices/wifi/wifi-mac-trailer.cc +++ b/src/devices/wifi/wifi-mac-trailer.cc @@ -51,18 +51,18 @@ WifiMacTrailer::Print (std::ostream &os) const uint32_t WifiMacTrailer::GetSerializedSize (void) const { - return 4; + return WIFI_MAC_FCS_LENGTH; } void WifiMacTrailer::Serialize (Buffer::Iterator start) const { - start.Prev (4); + start.Prev (WIFI_MAC_FCS_LENGTH); start.WriteU32 (0); } uint32_t WifiMacTrailer::Deserialize (Buffer::Iterator start) { - return 4; + return WIFI_MAC_FCS_LENGTH; } } // namespace ns3 diff --git a/src/devices/wifi/wifi-mac-trailer.h b/src/devices/wifi/wifi-mac-trailer.h index 717c12d70..d9071abbf 100644 --- a/src/devices/wifi/wifi-mac-trailer.h +++ b/src/devices/wifi/wifi-mac-trailer.h @@ -25,6 +25,11 @@ namespace ns3 { +/** + * The length in octects of the IEEE 802.11 MAC FCS field + */ +static const uint16_t WIFI_MAC_FCS_LENGTH = 4; + class WifiMacTrailer : public Trailer { public: diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index 54c7b5f6b..d6c43d8b4 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -43,10 +43,10 @@ WifiNetDevice::GetTypeId (void) .SetParent () .AddConstructor () .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit", - UintegerValue (MAX_MSDU_SIZE), + UintegerValue (MAX_MSDU_SIZE - LLC_SNAP_HEADER_LENGTH), MakeUintegerAccessor (&WifiNetDevice::SetMtu, &WifiNetDevice::GetMtu), - MakeUintegerChecker (1,MAX_MSDU_SIZE)) + MakeUintegerChecker (1,MAX_MSDU_SIZE - LLC_SNAP_HEADER_LENGTH)) .AddAttribute ("Channel", "The channel attached to this device", PointerValue (), MakePointerAccessor (&WifiNetDevice::DoGetChannel), @@ -191,7 +191,7 @@ WifiNetDevice::GetAddress (void) const bool WifiNetDevice::SetMtu (const uint16_t mtu) { - if (mtu > MAX_MSDU_SIZE) + if (mtu > MAX_MSDU_SIZE - LLC_SNAP_HEADER_LENGTH) { return false; } diff --git a/src/devices/wifi/wifi-remote-station-manager.cc b/src/devices/wifi/wifi-remote-station-manager.cc index a59fad07b..49e727956 100644 --- a/src/devices/wifi/wifi-remote-station-manager.cc +++ b/src/devices/wifi/wifi-remote-station-manager.cc @@ -29,6 +29,7 @@ #include "ns3/wifi-phy.h" #include "ns3/trace-source-accessor.h" #include "wifi-mac-header.h" +#include "wifi-mac-trailer.h" NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager"); @@ -151,15 +152,17 @@ WifiRemoteStationManager::GetTypeId (void) UintegerValue (7), MakeUintegerAccessor (&WifiRemoteStationManager::m_maxSlrc), MakeUintegerChecker ()) - .AddAttribute ("RtsCtsThreshold", "If a data packet is bigger than this value, we use an RTS/CTS handshake" - " before sending the data. This value will not have any effect on some rate control algorithms.", - UintegerValue (1500), + .AddAttribute ("RtsCtsThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than " + "this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2007, Section 9.2.6. " + "This value will not have any effect on some rate control algorithms.", + UintegerValue (2346), MakeUintegerAccessor (&WifiRemoteStationManager::m_rtsCtsThreshold), MakeUintegerChecker ()) - .AddAttribute ("FragmentationThreshold", "If a data packet is bigger than this value, we fragment it such that" - " the size of the fragments are equal or smaller than this value. This value will not have any effect" - " on some rate control algorithms.", - UintegerValue (1500), + .AddAttribute ("FragmentationThreshold", "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger" + "than this value, we fragment it such that the size of the fragments are equal or smaller " + "than this value, as per IEEE Std. 802.11-2007, Section 9.4. " + "This value will not have any effect on some rate control algorithms.", + UintegerValue (2346), MakeUintegerAccessor (&WifiRemoteStationManager::m_fragmentationThreshold), MakeUintegerChecker ()) .AddAttribute ("NonUnicastMode", "Wifi mode used for non-unicast transmissions.", @@ -458,7 +461,7 @@ WifiRemoteStationManager::NeedRts (Mac48Address address, const WifiMacHeader *he { return false; } - bool normally = packet->GetSize () > GetRtsCtsThreshold (); + bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetRtsCtsThreshold (); return DoNeedRts (Lookup (address, header), packet, normally); } bool @@ -488,7 +491,7 @@ WifiRemoteStationManager::NeedFragmentation (Mac48Address address, const WifiMac return false; } WifiRemoteStation *station = Lookup (address, header); - bool normally = packet->GetSize () > GetFragmentationThreshold (); + bool normally = (packet->GetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > GetFragmentationThreshold (); return DoNeedFragmentation (station, packet, normally); } uint32_t diff --git a/src/node/llc-snap-header.cc b/src/node/llc-snap-header.cc index 28c116d81..7cd98729d 100644 --- a/src/node/llc-snap-header.cc +++ b/src/node/llc-snap-header.cc @@ -43,7 +43,7 @@ LlcSnapHeader::GetType (void) uint32_t LlcSnapHeader::GetSerializedSize (void) const { - return 1 + 1 + 1 + 3 + 2; + return LLC_SNAP_HEADER_LENGTH; } TypeId diff --git a/src/node/llc-snap-header.h b/src/node/llc-snap-header.h index a4828fe3e..80fba3541 100644 --- a/src/node/llc-snap-header.h +++ b/src/node/llc-snap-header.h @@ -27,6 +27,11 @@ namespace ns3 { +/** + * The length in octects of the LLC/SNAP header + */ +static const uint16_t LLC_SNAP_HEADER_LENGTH = 8; + /** * \ingroup node *