Get node ID from MAC48Address without global variables

579 views
Skip to first unread message

Francisco Eduardo Balart Sanchez

unread,
Nov 29, 2016, 7:32:15 PM11/29/16
to ns-3-users
Good day:

I´m trying to simulate a MANET 
so far i have been able to retrieve by callbacks the MAC48address of the source node that sends packets
as well as retrieve the RSS 
One thing to mention, i only install the wifiMac and wifiPhy making at the end a wifinetdevice, meaning i´m not using Ipv4 or further classes which are used in common simulations, also i don´t use sta or ap mac classes but adhoc 

Since each node must only be able to "operate" with the neighbors information i must acquire the Node ID from a trace callbacks 
the two aforementioned i have used are:

  uint32_t nDevices = devices.GetN ();
  for (uint32_t i = 0;i < nDevices; ++i)
  {
    Ptr<WifiNetDevice> p = DynamicCast<WifiNetDevice> (devices.Get (i)); 
    p->SetAddress(Mac48Address::Allocate ());  
    devices.Get(i)->SetReceiveCallback(MakeCallback(&ReceivePacket));
    p->GetPhy()->TraceConnectWithoutContext ("MonitorSnifferRx", MakeCallback (&ReceivePacketWithRss));
  }

With which i get the MAC48Address of source node and the RSS as well
You can observe that i did not make global trace callbacks but one for each node since again i will work only with local information (that is the essence of my manet project)

Such callbacks are defined in the documentation as follows

void ReceivePacketWithRss (Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble,WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)

bool ReceivePacket( Ptr<NetDevice> netdevice, Ptr<const Packet> packet, uint16_t protocol, const Address& sourceAddress)

Now i have been digging in the forums to see if this has been done, but apologizing in advance i haven't seen a clear example
Such threads i have found are shown below:

So summarizing i would like support either by snippet of code or links to threads of discussions, or classes references to be able to retrieve if is possible
the Source Node ID from the MAC48Address without the need of use of global variables (mapping it) and if possible using the info of one of the callbacks i already have implemented, if i need to implement another callback i have no problem

I apologize in advance if this has been answered already, but i haven´t found the answer yet, or it was not clear to me a newbie in NS3 if it was already there 

Thanks in advance and best regards

Eduardo

    Francisco Eduardo Balart Sanchez

    unread,
    Jan 24, 2017, 3:43:27 PM1/24/17
    to ns-3-users
    Good day:

    Just following up if there is any update regarding the support for this topic

      Tommaso Pecorella

      unread,
      Jan 29, 2017, 7:47:34 PM1/29/17
      to ns-3-users
      Hi Eduardo,

      I fear that there's no solution to your problem.

      If you use global variables (e.g., the global node list) NodeList::GetNode(i) you can get the nodes pointer, scan it for its interfaces, see if one of them has a matching MacAddress and, in case, retrieve the NodeId.
      If you don't use global variables, you can't do that, and there's no foolproof way to find the NodeId from the MAC address.

      As a matter of fact, remember that the NodeId is a ns-3 thing. A real system won't care about the NodeId, nodes will be always identified by their MAC address.
      In case you want to use a higher level identifier, you'll need a discovery system similar to ARP and/or NDP.

      Cheers,

      T.

      Francisco Eduardo Balart Sanchez

      unread,
      Jan 30, 2017, 1:38:12 PM1/30/17
      to ns-3-users
      Good day:

      Thanks for taking the time Tommasso, i think this solves my doubt, right now as you said i´m using global variables but for the communications between nodes its MAC address.

      thanks.
      Reply all
      Reply to author
      Forward
      0 new messages