--- a/examples/ipv6/wsn-ping6.cc Sun Mar 16 20:46:00 2014 +0100
+++ b/examples/ipv6/wsn-ping6.cc Sun Mar 16 22:33:50 2014 +0100
@@ -87,6 +87,7 @@
// Add and install the LrWpanNetDevice for each node
// lrWpanHelper.EnableLogComponents();
NetDeviceContainer devContainer = lrWpanHelper.Install(nodes);
+ lrWpanHelper.AssociateToPan (devContainer, 10);
std::cout << "Created " << devContainer.GetN() << " devices" << std::endl;
std::cout << "There are " << nodes.GetN() << " nodes" << std::endl;
--- a/src/lr-wpan/helper/lr-wpan-helper.cc Sun Mar 16 20:46:00 2014 +0100
+++ b/src/lr-wpan/helper/lr-wpan-helper.cc Sun Mar 16 22:33:50 2014 +0100
@@ -171,6 +171,31 @@
return devices;
}
+void
+LrWpanHelper::AssociateToPan (NetDeviceContainer c, uint16_t panId)
+{
+ NetDeviceContainer devices;
+ uint16_t id = 1;
+ uint8_t idBuf[2];
+
+ for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); i++)
+ {
+ Ptr<LrWpanNetDevice> device = DynamicCast<LrWpanNetDevice> (*i);
+ if (device)
+ {
+ idBuf[0] = (id >> 8) & 0xff;
+ idBuf[1] = (id >> 0) & 0xff;
+ Mac16Address address;
+ address.CopyFrom (idBuf);
+
+ device->GetMac ()->SetPanId (panId);
+ device->GetMac ()->SetShortAddress (address);
+ id++;
+ }
+ }
+ return;
+}
+
static void
PcapSniffLrWpan (Ptr<PcapFileWrapper> file, Ptr<const Packet> packet)
{
--- a/src/lr-wpan/helper/lr-wpan-helper.h Sun Mar 16 20:46:00 2014 +0100
+++ b/src/lr-wpan/helper/lr-wpan-helper.h Sun Mar 16 22:33:50 2014 +0100
@@ -65,6 +65,14 @@
NetDeviceContainer Install (NodeContainer c);
/**
+ * \brief Associate the nodes to the same PAN
+ *
+ * \param c a set of nodes
+ * \param panId the PAN Id
+ */
+ void AssociateToPan (NetDeviceContainer c, uint16_t panId);
+
+ /**
* Helper to enable all LrWpan log components with one statement
*/
void EnableLogComponents (void);
--- a/src/lr-wpan/model/lr-wpan-mac.cc Sun Mar 16 20:46:00 2014 +0100
+++ b/src/lr-wpan/model/lr-wpan-mac.cc Sun Mar 16 22:33:50 2014 +0100
@@ -106,7 +106,7 @@
UniformVariable uniformVar;
uniformVar = UniformVariable (0, 255);
m_macDsn = SequenceNumber16 (uniformVar.GetValue ());
- m_shortAddress = Mac16Address::Allocate ();
+ m_shortAddress = Mac16Address ("00:00");
}
LrWpanMac::~LrWpanMac ()