diff --git a/CHANGES.md b/CHANGES.md index 32a40a76c76..cecfaee95cb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,7 @@ Changes from ns-3.40 to ns-3-dev * (spectrum) `PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity` return type is changed from `Ptr` to `Ptr` to support MIMO, because when multiple transmit and receive antenna ports are present, it is not enough to have a single PSD (represented by `Ptr`) but also the 3D channel matrix is needed per receive and transmit antenna port. Notice that `CalcRxPowerSpectralDensity` is typically called from within `MultiModelSpectrumChannel`, but if some external ns-3 module is calling directly this function, it can still access to its original return value through `Ptr` which contains `Ptr`. * (wifi) The default value for `WifiRemoteStationManager::RtsCtsThreshold` has been increased from 65535 to 4692480. * (lr-wpan) Add the capability to see the enum values of the MAC transition states in log prints for easier debugging. +* (sixlowpan) Remove `ForceEtherType` and `EtherType` attributes, and use RFC 7973 EtherType for interfaces supporting an EtherType. ### Changes to build system diff --git a/src/sixlowpan/doc/sixlowpan.rst b/src/sixlowpan/doc/sixlowpan.rst index 09336e94f8e..08afb0b466e 100644 --- a/src/sixlowpan/doc/sixlowpan.rst +++ b/src/sixlowpan/doc/sixlowpan.rst @@ -52,8 +52,6 @@ The attributes are: * FragmentReassemblyListSize (integer, default 0), indicating the number of packets that can be reassembled at the same time. If the limit is reached, the oldest packet is discarded. Zero means infinite. * FragmentExpirationTimeout (Time, default 60 seconds), being the timeout to wait for further fragments before discarding a partial packet. * CompressionThreshold (unsigned 32 bits integer, default 0), minimum compressed payload size. -* ForceEtherType (boolean, default false). -* EtherType (unsigned 16 bits integer, default 0xFFFF), to force a particular L2 EtherType. * UseMeshUnder (boolean, default false), it enables mesh-under flood routing. * MeshUnderRadius (unsigned 8 bits integer, default 10), the maximum number of hops that a packet will be forwarded. * MeshCacheLength (unsigned 16 bits integer, default 10), the length of the cache for each source. @@ -65,23 +63,8 @@ used (plus one byte for the correct dispatch header). This option is useful when a MAC requires a minimum frame size (e.g., ContikiMAC) and the compression would violate the requirement. -The last two attributes are needed to use the module with a NetDevice other than 802.15.4, as -neither IANA or IEEE did reserve an EtherType for 6LoWPAN. As a consequence there might be a -conflict with the L2 multiplexer/demultiplexer which is based on EtherType. The default -value is 0xFFFF, which is reserved by IEEE (see [IANA802]_ and [Ethertype]_). -The default module behaviour is to not change the EtherType, however this would not work with -any NetDevice actually understanding and using the EtherType. - -Note that the `ForceEtherType` parameter have also a direct effect on the MAC address kind the -module is expecting to handle: -* ForceEtherType true: Mac48Address (Ethernet, WiFi, etc.). -* ForceEtherType false: Mac16Address or Mac64Address (IEEE 802.15.4). - -Note that using 6LoWPAN over any NetDevice other than 802.15.4 will produce valid .pcap files, -but they will not be correctly dissected by Wireshark. -The reason lies on the fact that 6LoWPAN was really meant to be used only over 802.15.4, so -Wireshark dissectors will not even try to decode 6LoWPAN headers on top of protocols other than -802.15.4. +Note that 6LoWPAN will use an EtherType equal to 0xA0ED, as mandated by :rfc:`7973`. +If the device does not support EtherTypes (e.g., 802.15.4), this value is discarded. The Trace sources are: diff --git a/src/sixlowpan/examples/example-sixlowpan.cc b/src/sixlowpan/examples/example-sixlowpan.cc index fc9884f40fc..de7b00da6fa 100644 --- a/src/sixlowpan/examples/example-sixlowpan.cc +++ b/src/sixlowpan/examples/example-sixlowpan.cc @@ -88,7 +88,6 @@ main(int argc, char** argv) NetDeviceContainer d1 = csma.Install(net1); SixLowPanHelper sixlowpan; - sixlowpan.SetDeviceAttribute("ForceEtherType", BooleanValue(true)); NetDeviceContainer six1 = sixlowpan.Install(d1); NS_LOG_INFO("Create networks and assign IPv6 Addresses."); diff --git a/src/sixlowpan/model/sixlowpan-net-device.cc b/src/sixlowpan/model/sixlowpan-net-device.cc index edb6b23eeb0..a9eef7a791e 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.cc +++ b/src/sixlowpan/model/sixlowpan-net-device.cc @@ -83,16 +83,6 @@ SixLowPanNetDevice::GetTypeId() UintegerValue(0x0), MakeUintegerAccessor(&SixLowPanNetDevice::m_compressionThreshold), MakeUintegerChecker()) - .AddAttribute("ForceEtherType", - "Force a specific EtherType in L2 frames.", - BooleanValue(false), - MakeBooleanAccessor(&SixLowPanNetDevice::m_forceEtherType), - MakeBooleanChecker()) - .AddAttribute("EtherType", - "The specific EtherType to be used in L2 frames.", - UintegerValue(0xFFFF), - MakeUintegerAccessor(&SixLowPanNetDevice::m_etherType), - MakeUintegerChecker()) .AddAttribute("UseMeshUnder", "Use a mesh-under routing protocol.", BooleanValue(false), @@ -158,10 +148,13 @@ SixLowPanNetDevice::SetNetDevice(Ptr device) NS_LOG_DEBUG("RegisterProtocolHandler for " << device->GetInstanceTypeId().GetName()); - uint16_t protocolType = 0; - if (m_forceEtherType) + uint16_t protocolType = PROT_NUMBER; + if (device->GetInstanceTypeId().GetName() == "ns3::LrWpanNetDevice") { - protocolType = m_etherType; + // LrWpanNetDevice does not have a protocol number in the frame. + // Hence, we must register for any protocol, and assume that any + // packet is 6LoWPAN. + protocolType = 0; } m_node->RegisterProtocolHandler(MakeCallback(&SixLowPanNetDevice::ReceiveFromDevice, this), protocolType, @@ -596,10 +589,7 @@ SixLowPanNetDevice::DoSend(Ptr packet, bool useMesh = m_meshUnder; - if (m_forceEtherType) - { - protocolNumber = m_etherType; - } + protocolNumber = PROT_NUMBER; if (m_useIphc) { diff --git a/src/sixlowpan/model/sixlowpan-net-device.h b/src/sixlowpan/model/sixlowpan-net-device.h index ff3a8d4f924..b4f75c34be2 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.h +++ b/src/sixlowpan/model/sixlowpan-net-device.h @@ -85,6 +85,11 @@ class SixLowPanNetDevice : public NetDevice //!< context }; + /** + * \brief The protocol number for 6LoWPAN (0xA0ED) - see \RFC{7973}. + */ + static constexpr uint16_t PROT_NUMBER{0xA0ED}; + /** * \brief Get the type ID. * \return The object TypeId. @@ -626,14 +631,6 @@ class SixLowPanNetDevice : public NetDevice Ptr m_netDevice; //!< Smart pointer to the underlying NetDevice. uint32_t m_ifIndex; //!< Interface index. - /** - * \brief Force the EtherType number. - * Also implying that the underlying NetDevice is using 48-bit Addresses, e.g., Ethernet, Wi-Fi, - * etc. - */ - bool m_forceEtherType; - - uint16_t m_etherType; //!< EtherType number (used only if m_forceEtherType is true). bool m_omitUdpChecksum; //!< Omit UDP checksum in NC1 encoding. uint32_t m_compressionThreshold; //!< Minimum L2 payload size. diff --git a/src/sixlowpan/test/sixlowpan-fragmentation-test.cc b/src/sixlowpan/test/sixlowpan-fragmentation-test.cc index d7a08294546..aa7ed544d3c 100644 --- a/src/sixlowpan/test/sixlowpan-fragmentation-test.cc +++ b/src/sixlowpan/test/sixlowpan-fragmentation-test.cc @@ -289,7 +289,6 @@ SixlowpanFragmentationTest::DoRun() serverNode->AddDevice(serverDev); Ptr serverSix = CreateObject(); - serverSix->SetAttribute("ForceEtherType", BooleanValue(true)); serverNode->AddDevice(serverSix); serverSix->SetNetDevice(serverDev); @@ -320,7 +319,6 @@ SixlowpanFragmentationTest::DoRun() clientNode->AddDevice(clientDev); Ptr clientSix = CreateObject(); - clientSix->SetAttribute("ForceEtherType", BooleanValue(true)); clientNode->AddDevice(clientSix); clientSix->SetNetDevice(clientDev); diff --git a/src/sixlowpan/test/sixlowpan-hc1-test.cc b/src/sixlowpan/test/sixlowpan-hc1-test.cc index 65ac2e167cd..2693ae0c579 100644 --- a/src/sixlowpan/test/sixlowpan-hc1-test.cc +++ b/src/sixlowpan/test/sixlowpan-hc1-test.cc @@ -142,7 +142,6 @@ SixlowpanHc1ImplTest::DoRun() rxNode->AddDevice(rxDev); Ptr rxSix = CreateObject(); - rxSix->SetAttribute("ForceEtherType", BooleanValue(true)); rxSix->SetAttribute("Rfc6282", BooleanValue(false)); rxNode->AddDevice(rxSix); rxSix->SetNetDevice(rxDev); @@ -166,7 +165,6 @@ SixlowpanHc1ImplTest::DoRun() txNode->AddDevice(txDev); Ptr txSix = CreateObject(); - txSix->SetAttribute("ForceEtherType", BooleanValue(true)); txSix->SetAttribute("Rfc6282", BooleanValue(false)); txNode->AddDevice(txSix); txSix->SetNetDevice(txDev); diff --git a/src/sixlowpan/test/sixlowpan-iphc-test.cc b/src/sixlowpan/test/sixlowpan-iphc-test.cc index 1400b2beaa5..3123151006b 100644 --- a/src/sixlowpan/test/sixlowpan-iphc-test.cc +++ b/src/sixlowpan/test/sixlowpan-iphc-test.cc @@ -142,7 +142,6 @@ SixlowpanIphcImplTest::DoRun() rxNode->AddDevice(rxDev); Ptr rxSix = CreateObject(); - rxSix->SetAttribute("ForceEtherType", BooleanValue(true)); rxNode->AddDevice(rxSix); rxSix->SetNetDevice(rxDev); @@ -165,7 +164,6 @@ SixlowpanIphcImplTest::DoRun() txNode->AddDevice(txDev); Ptr txSix = CreateObject(); - txSix->SetAttribute("ForceEtherType", BooleanValue(true)); txNode->AddDevice(txSix); txSix->SetNetDevice(txDev);