lrwpan: support for extended addressing mode
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -162,6 +162,7 @@ Varun Reddy (varunamarreddy@gmail.com)
|
||||
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)
|
||||
|
||||
@@ -58,6 +58,7 @@ us a note on ns-developers mailing list.</p>
|
||||
</ul>
|
||||
<h2>Changes to existing API:</h2>
|
||||
<ul>
|
||||
<li> Class <b>LrWpanMac</b> now supports extended addressing mode. Both <b>McpsDataRequest</b> and <b>PdDataIndication</b> methods will now use extended addressing if <b>McpsDataRequestParams::m_srcAddrMode</b> or <b>McpsDataRequestParams::m_dstAddrMode</b> are set to <b>EXT_ADDR</b>.
|
||||
</ul>
|
||||
<h2>Changes to build system:</h2>
|
||||
<ul>
|
||||
|
||||
@@ -25,6 +25,7 @@ This release has been tested on the following platforms:
|
||||
|
||||
New user-visible features
|
||||
-------------------------
|
||||
- (lr-wpan) Extended addressing mode is now supported.
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
@@ -59,10 +59,12 @@ static void StateChangeNotification (std::string context, Time now, LrWpanPhyEnu
|
||||
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 @@ int main (int argc, char *argv[])
|
||||
Ptr<LrWpanNetDevice> dev0 = CreateObject<LrWpanNetDevice> ();
|
||||
Ptr<LrWpanNetDevice> dev1 = CreateObject<LrWpanNetDevice> ();
|
||||
|
||||
dev0->SetAddress (Mac16Address ("00:01"));
|
||||
dev1->SetAddress (Mac16Address ("00:02"));
|
||||
if (!extended)
|
||||
{
|
||||
dev0->SetAddress (Mac16Address ("00:01"));
|
||||
dev1->SetAddress (Mac16Address ("00:02"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Ptr<LrWpanMac> mac0 = dev0->GetMac();
|
||||
Ptr<LrWpanMac> 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<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel> ();
|
||||
@@ -138,10 +150,19 @@ int main (int argc, char *argv[])
|
||||
// 2) DataIndication callback is called with value of 50
|
||||
Ptr<Packet> p0 = Create<Packet> (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 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Send a packet back at time 2 seconds
|
||||
Ptr<Packet> p2 = Create<Packet> (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);
|
||||
|
||||
@@ -312,10 +312,33 @@ LrWpanMac::McpsDataRequest (McpsDataRequestParams params, Ptr<Packet> p)
|
||||
}
|
||||
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 @@ LrWpanMac::PdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
|
||||
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
|
||||
|
||||
@@ -158,6 +158,7 @@ struct McpsDataRequestParams
|
||||
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 @@ struct McpsDataIndicationParams
|
||||
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
|
||||
};
|
||||
|
||||
@@ -67,6 +67,21 @@ public:
|
||||
* \param params The MCPS params.
|
||||
*/
|
||||
static void DataConfirm (LrWpanAckTestCase *testCase, Ptr<LrWpanNetDevice> 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<LrWpanNetDevice> dev, McpsDataIndicationParams params, Ptr<Packet> 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<LrWpanNetDevice> dev, McpsDataConfirmParams params);
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
@@ -124,6 +139,42 @@ LrWpanAckTestCase::DataConfirm (LrWpanAckTestCase *testCase, Ptr<LrWpanNetDevice
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LrWpanAckTestCase::ExtendedAddressingDataIndication (LrWpanAckTestCase *testCase, Ptr<LrWpanNetDevice> dev, McpsDataIndicationParams params, Ptr<Packet> p)
|
||||
{
|
||||
if (dev->GetMac ()->GetExtendedAddress () == Mac64Address ("00:00:00:00:00:00:00:02"))
|
||||
{
|
||||
Ptr<Packet> p = Create<Packet> (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<LrWpanNetDevice> 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)
|
||||
{
|
||||
@@ -133,6 +184,7 @@ LrWpanAckTestCase::DoRun (void)
|
||||
// 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 @@ LrWpanAckTestCase::DoRun (void)
|
||||
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<Packet> p1 = Create<Packet> (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 ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user