Index: AUTHORS
===================================================================
--- a/AUTHORS
+++ b/AUTHORS
@@ -162,6 +162,7 @@
Ken Renard (kenneth.renard@arl.army.mil)
Getachew Redieteab (redieteab.orange@gmail.com)
Manuel Requena (mrequena@cttc.es)
+Jakub Rewienski (jrewienski@gmail.com)
Matias Richart (mrichart@fing.edu.uy)
George F. Riley (riley@ece.gatech.edu)
Juergen Rinas (jrinas@gmx.de)
Index: CHANGES.html
===================================================================
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -58,6 +58,7 @@
Changes to existing API:
+ - Class LrWpanMac now supports extended addressing mode. Both McpsDataRequest and PdDataIndication methods will now use extended addressing if McpsDataRequestParams::m_srcAddrMode or McpsDataRequestParams::m_dstAddrMode are set to EXT_ADDR.
Changes to build system:
Index: RELEASE_NOTES
===================================================================
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -25,6 +25,7 @@
New user-visible features
-------------------------
+- (lr-wpan) Extended addressing mode is now supported.
Bugs fixed
----------
Index: src/lr-wpan/examples/lr-wpan-data.cc
===================================================================
--- a/src/lr-wpan/examples/lr-wpan-data.cc
+++ b/src/lr-wpan/examples/lr-wpan-data.cc
@@ -59,10 +59,12 @@
int main (int argc, char *argv[])
{
bool verbose = false;
+ bool extended = false;
CommandLine cmd;
cmd.AddValue ("verbose", "turn on all log components", verbose);
+ cmd.AddValue ("extended", "use extended addressing", extended);
cmd.Parse (argc, argv);
@@ -82,8 +84,18 @@
Ptr dev0 = CreateObject ();
Ptr dev1 = CreateObject ();
- dev0->SetAddress (Mac16Address ("00:01"));
- dev1->SetAddress (Mac16Address ("00:02"));
+ if (!extended)
+ {
+ dev0->SetAddress (Mac16Address ("00:01"));
+ dev1->SetAddress (Mac16Address ("00:02"));
+ }
+ else
+ {
+ Ptr mac0 = dev0->GetMac();
+ Ptr mac1 = dev1->GetMac();
+ mac0->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:01"));
+ mac1->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:02"));
+ }
// Each device must be attached to the same channel
Ptr channel = CreateObject ();
@@ -138,10 +150,19 @@
// 2) DataIndication callback is called with value of 50
Ptr p0 = Create (50); // 50 bytes of dummy data
McpsDataRequestParams params;
- params.m_srcAddrMode = SHORT_ADDR;
- params.m_dstAddrMode = SHORT_ADDR;
params.m_dstPanId = 0;
- params.m_dstAddr = Mac16Address ("00:02");
+ if (!extended)
+ {
+ params.m_srcAddrMode = SHORT_ADDR;
+ params.m_dstAddrMode = SHORT_ADDR;
+ params.m_dstAddr = Mac16Address ("00:02");
+ }
+ else
+ {
+ params.m_srcAddrMode = EXT_ADDR;
+ params.m_dstAddrMode = EXT_ADDR;
+ params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:02");
+ }
params.m_msduHandle = 0;
params.m_txOptions = TX_OPTION_ACK;
// dev0->GetMac ()->McpsDataRequest (params, p0);
@@ -151,7 +172,14 @@
// Send a packet back at time 2 seconds
Ptr p2 = Create (60); // 60 bytes of dummy data
- params.m_dstAddr = Mac16Address ("00:01");
+ if (!extended)
+ {
+ params.m_dstAddr = Mac16Address ("00:01");
+ }
+ else
+ {
+ params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:01");
+ }
Simulator::ScheduleWithContext (2, Seconds (2.0),
&LrWpanMac::McpsDataRequest,
dev1->GetMac (), params, p2);
Index: src/lr-wpan/model/lr-wpan-mac.cc
===================================================================
--- a/src/lr-wpan/model/lr-wpan-mac.cc
+++ b/src/lr-wpan/model/lr-wpan-mac.cc
@@ -312,10 +312,33 @@
}
return;
}
+ switch (params.m_dstAddrMode)
+ {
+ case NO_PANID_ADDR:
+ macHdr.SetDstAddrMode (params.m_dstAddrMode);
+ macHdr.SetNoPanIdComp ();
+ break;
+ case ADDR_MODE_RESERVED:
+ NS_ABORT_MSG ("Can not set destination address type to ADDR_MODE_RESERVED. Aborting.");
+ break;
+ case SHORT_ADDR:
+ macHdr.SetDstAddrMode (params.m_dstAddrMode);
+ macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
+ break;
+ case EXT_ADDR:
+ macHdr.SetDstAddrMode (params.m_dstAddrMode);
+ macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstExtAddr);
+ break;
+ default:
+ NS_LOG_ERROR (this << " Can not send packet with incorrect Destination Address mode = " << params.m_dstAddrMode);
+ confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
+ if (!m_mcpsDataConfirmCallback.IsNull ())
+ {
+ m_mcpsDataConfirmCallback (confirmParams);
+ }
+ return;
+ }
- macHdr.SetDstAddrMode (params.m_dstAddrMode);
- // TODO: Add field for EXT_ADDR destination address (and use it here).
- macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
macHdr.SetSecDisable ();
//extract the last 3 bits in TxOptions and map to macHdr
int b0 = params.m_txOptions & TX_OPTION_ACK;
@@ -512,21 +535,35 @@
params.m_mpduLinkQuality = lqi;
params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
- // TODO: Add field for EXT_ADDR source address.
- if (params.m_srcAddrMode == SHORT_ADDR)
+ switch (params.m_srcAddrMode)
{
+ case SHORT_ADDR:
params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
+ NS_LOG_DEBUG ("Packet from " << params.m_srcAddr);
+ break;
+ case EXT_ADDR:
+ params.m_srcExtAddr = receivedMacHdr.GetExtSrcAddr ();
+ NS_LOG_DEBUG ("Packet from " << params.m_srcExtAddr);
+ break;
+ default:
+ break;
}
params.m_dstPanId = receivedMacHdr.GetDstPanId ();
params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
- // TODO: Add field for EXT_ADDR destination address.
- if (params.m_dstAddrMode == SHORT_ADDR)
+ switch (params.m_dstAddrMode)
{
+ case SHORT_ADDR:
params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
+ NS_LOG_DEBUG ("Packet to " << params.m_dstAddr);
+ break;
+ case EXT_ADDR:
+ params.m_dstExtAddr = receivedMacHdr.GetExtDstAddr ();
+ NS_LOG_DEBUG ("Packet to " << params.m_dstExtAddr);
+ break;
+ default:
+ break;
}
- NS_LOG_DEBUG ("Packet from " << params.m_srcAddr << " to " << params.m_dstAddr);
-
if (m_macPromiscuousMode)
{
//level 2 filtering
Index: src/lr-wpan/model/lr-wpan-mac.h
===================================================================
--- a/src/lr-wpan/model/lr-wpan-mac.h
+++ b/src/lr-wpan/model/lr-wpan-mac.h
@@ -158,6 +158,7 @@
LrWpanAddressMode m_dstAddrMode; //!< Destination address mode
uint16_t m_dstPanId; //!< Destination PAN identifier
Mac16Address m_dstAddr; //!< Destination address
+ Mac64Address m_dstExtAddr; //!< Destination extended address
uint8_t m_msduHandle; //!< MSDU handle
uint8_t m_txOptions; //!< Tx Options (bitfield)
};
@@ -183,9 +184,11 @@
uint8_t m_srcAddrMode; //!< Source address mode
uint16_t m_srcPanId; //!< Source PAN identifier
Mac16Address m_srcAddr; //!< Source address
+ Mac64Address m_srcExtAddr; //!< Source extended address
uint8_t m_dstAddrMode; //!< Destination address mode
uint16_t m_dstPanId; //!< Destination PAN identifier
Mac16Address m_dstAddr; //!< Destination address
+ Mac64Address m_dstExtAddr; //!< Destination extended address
uint8_t m_mpduLinkQuality; //!< LQI value measured during reception of the MPDU
uint8_t m_dsn; //!< The DSN of the received data frame
};
Index: src/lr-wpan/test/lr-wpan-ack-test.cc
===================================================================
--- a/src/lr-wpan/test/lr-wpan-ack-test.cc
+++ b/src/lr-wpan/test/lr-wpan-ack-test.cc
@@ -67,6 +67,21 @@
* \param params The MCPS params.
*/
static void DataConfirm (LrWpanAckTestCase *testCase, Ptr dev, McpsDataConfirmParams params);
+ /**
+ * \brief Function called when DataIndication is hit in extended addressing test.
+ * \param testCase The TestCase.
+ * \param dev The LrWpanNetDevice.
+ * \param params The MCPS params.
+ * \param p the packet.
+ */
+ static void ExtendedAddressingDataIndication (LrWpanAckTestCase *testCase, Ptr dev, McpsDataIndicationParams params, Ptr p);
+ /**
+ * \brief Function called when DataConfirm is hit in extended addressing test.
+ * \param testCase The TestCase.
+ * \param dev The LrWpanNetDevice.
+ * \param params The MCPS params.
+ */
+ static void ExtendedAddressingDataConfirm (LrWpanAckTestCase *testCase, Ptr dev, McpsDataConfirmParams params);
private:
virtual void DoRun (void);
@@ -125,6 +140,42 @@
}
void
+LrWpanAckTestCase::ExtendedAddressingDataIndication (LrWpanAckTestCase *testCase, Ptr dev, McpsDataIndicationParams params, Ptr p)
+{
+ if (dev->GetMac ()->GetExtendedAddress () == Mac64Address ("00:00:00:00:00:00:00:02"))
+ {
+ Ptr p = Create (10); // 10 bytes of dummy data
+ McpsDataRequestParams params;
+ params.m_srcAddrMode = EXT_ADDR;
+ params.m_dstAddrMode = EXT_ADDR;
+ params.m_dstPanId = 0;
+ params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:01");
+ params.m_msduHandle = 0;
+ params.m_txOptions = TX_OPTION_NONE;
+
+ testCase->m_replyTime = Simulator::Now ();
+ dev->GetMac ()->McpsDataRequest (params, p);
+ }
+ else
+ {
+ testCase->m_replyArrivalTime = Simulator::Now ();
+ }
+}
+
+void
+LrWpanAckTestCase::ExtendedAddressingDataConfirm (LrWpanAckTestCase *testCase, Ptr dev, McpsDataConfirmParams params)
+{
+ if (dev->GetMac ()->GetExtendedAddress () == Mac64Address ("00:00:00:00:00:00:00:01"))
+ {
+ testCase->m_requestAckTime = Simulator::Now ();
+ }
+ else
+ {
+ testCase->m_replyAckTime = Simulator::Now ();
+ }
+}
+
+void
LrWpanAckTestCase::DoRun (void)
{
// Test setup:
@@ -133,6 +184,7 @@
// immediately answers with a reply packet on reception of the request.
// We expect the ACK of the request packet to always arrive at node 1 before
// the reply packet sent by node 2.
+ // The same is repeated for extened addressing mode.
// Enable calculation of FCS in the trailers. Only necessary when interacting with real devices or wireshark.
// GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
@@ -211,6 +263,49 @@
NS_TEST_EXPECT_MSG_LT (m_requestAckTime, m_replyArrivalTime, "The request was ACKed before the reply arrived (as expected)");
NS_TEST_EXPECT_MSG_LT (m_replyAckTime, m_replyArrivalTime, "The reply was ACKed before the reply arrived (as expected)");
+ // Test extended addressing.
+
+ // Resetting the timers.
+ m_requestTime = Seconds (0);
+ m_requestAckTime = Seconds (0);
+ m_replyTime = Seconds (0);
+ m_replyAckTime = Seconds (0);
+ m_replyArrivalTime = Seconds (0);
+
+ // Adding exteneded addresses.
+ dev0->GetMac()->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:01"));
+ dev1->GetMac()->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:02"));
+
+ // Changing callbacks for those with exteneded addressing.
+ cb0 = MakeBoundCallback (&LrWpanAckTestCase::ExtendedAddressingDataConfirm, this, dev0);
+ dev0->GetMac ()->SetMcpsDataConfirmCallback (cb0);
+
+ cb1 = MakeBoundCallback (&LrWpanAckTestCase::ExtendedAddressingDataIndication, this, dev0);
+ dev0->GetMac ()->SetMcpsDataIndicationCallback (cb1);
+
+ cb2 = MakeBoundCallback (&LrWpanAckTestCase::ExtendedAddressingDataConfirm, this, dev1);
+ dev1->GetMac ()->SetMcpsDataConfirmCallback (cb2);
+
+ cb3 = MakeBoundCallback (&LrWpanAckTestCase::ExtendedAddressingDataIndication, this, dev1);
+ dev1->GetMac ()->SetMcpsDataIndicationCallback (cb3);
+
+ Ptr p1 = Create (50); // 50 bytes of dummy data
+ params.m_srcAddrMode = EXT_ADDR;
+ params.m_dstAddrMode = EXT_ADDR;
+ params.m_dstPanId = 0;
+ params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:02");
+ params.m_msduHandle = 0;
+ params.m_txOptions = TX_OPTION_ACK;
+ m_requestTime = Simulator::Now ();
+ Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->GetMac (), params, p0);
+
+
+ Simulator::Run ();
+
+ NS_TEST_EXPECT_MSG_LT (m_requestTime, m_replyTime, "ExtendedAddressing: Sent the request before the reply (as expected)");
+ NS_TEST_EXPECT_MSG_LT (m_requestAckTime, m_replyArrivalTime, "ExtendedAddressing: The request was ACKed before the reply arrived (as expected)");
+ NS_TEST_EXPECT_MSG_LT (m_replyAckTime, m_replyArrivalTime, "ExtendedAddressing: The reply was ACKed before the reply arrived (as expected)");
+
Simulator::Destroy ();
}