Skip to content

Commit

Permalink
sixlowpan: use RFC7973 EtherType and remove obsolete attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyPec committed Jan 18, 2024
1 parent d5f9dc2 commit 6636d62
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Changes from ns-3.40 to ns-3-dev
* (spectrum) `PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity` return type is changed from `Ptr<SpectrumValue>` to `Ptr<SpectrumSignalParameters>` 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<SpectrumValue>`) 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<SpectrumSignalParameters>` which contains `Ptr<SpectrumValue>`.
* (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

Expand Down
21 changes: 2 additions & 19 deletions src/sixlowpan/doc/sixlowpan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down
1 change: 0 additions & 1 deletion src/sixlowpan/examples/example-sixlowpan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
24 changes: 7 additions & 17 deletions src/sixlowpan/model/sixlowpan-net-device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ SixLowPanNetDevice::GetTypeId()
UintegerValue(0x0),
MakeUintegerAccessor(&SixLowPanNetDevice::m_compressionThreshold),
MakeUintegerChecker<uint32_t>())
.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<uint16_t>())
.AddAttribute("UseMeshUnder",
"Use a mesh-under routing protocol.",
BooleanValue(false),
Expand Down Expand Up @@ -158,10 +148,13 @@ SixLowPanNetDevice::SetNetDevice(Ptr<NetDevice> 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,
Expand Down Expand Up @@ -596,10 +589,7 @@ SixLowPanNetDevice::DoSend(Ptr<Packet> packet,

bool useMesh = m_meshUnder;

if (m_forceEtherType)
{
protocolNumber = m_etherType;
}
protocolNumber = PROT_NUMBER;

if (m_useIphc)
{
Expand Down
13 changes: 5 additions & 8 deletions src/sixlowpan/model/sixlowpan-net-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -626,14 +631,6 @@ class SixLowPanNetDevice : public NetDevice
Ptr<NetDevice> 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.
Expand Down
2 changes: 0 additions & 2 deletions src/sixlowpan/test/sixlowpan-fragmentation-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ SixlowpanFragmentationTest::DoRun()
serverNode->AddDevice(serverDev);

Ptr<SixLowPanNetDevice> serverSix = CreateObject<SixLowPanNetDevice>();
serverSix->SetAttribute("ForceEtherType", BooleanValue(true));
serverNode->AddDevice(serverSix);
serverSix->SetNetDevice(serverDev);

Expand Down Expand Up @@ -320,7 +319,6 @@ SixlowpanFragmentationTest::DoRun()
clientNode->AddDevice(clientDev);

Ptr<SixLowPanNetDevice> clientSix = CreateObject<SixLowPanNetDevice>();
clientSix->SetAttribute("ForceEtherType", BooleanValue(true));
clientNode->AddDevice(clientSix);
clientSix->SetNetDevice(clientDev);

Expand Down
2 changes: 0 additions & 2 deletions src/sixlowpan/test/sixlowpan-hc1-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ SixlowpanHc1ImplTest::DoRun()
rxNode->AddDevice(rxDev);

Ptr<SixLowPanNetDevice> rxSix = CreateObject<SixLowPanNetDevice>();
rxSix->SetAttribute("ForceEtherType", BooleanValue(true));
rxSix->SetAttribute("Rfc6282", BooleanValue(false));
rxNode->AddDevice(rxSix);
rxSix->SetNetDevice(rxDev);
Expand All @@ -166,7 +165,6 @@ SixlowpanHc1ImplTest::DoRun()
txNode->AddDevice(txDev);

Ptr<SixLowPanNetDevice> txSix = CreateObject<SixLowPanNetDevice>();
txSix->SetAttribute("ForceEtherType", BooleanValue(true));
txSix->SetAttribute("Rfc6282", BooleanValue(false));
txNode->AddDevice(txSix);
txSix->SetNetDevice(txDev);
Expand Down
2 changes: 0 additions & 2 deletions src/sixlowpan/test/sixlowpan-iphc-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ SixlowpanIphcImplTest::DoRun()
rxNode->AddDevice(rxDev);

Ptr<SixLowPanNetDevice> rxSix = CreateObject<SixLowPanNetDevice>();
rxSix->SetAttribute("ForceEtherType", BooleanValue(true));
rxNode->AddDevice(rxSix);
rxSix->SetNetDevice(rxDev);

Expand All @@ -165,7 +164,6 @@ SixlowpanIphcImplTest::DoRun()
txNode->AddDevice(txDev);

Ptr<SixLowPanNetDevice> txSix = CreateObject<SixLowPanNetDevice>();
txSix->SetAttribute("ForceEtherType", BooleanValue(true));
txNode->AddDevice(txSix);
txSix->SetNetDevice(txDev);

Expand Down

0 comments on commit 6636d62

Please sign in to comment.