Number of transmitted/received packet in the Mac layer

187 views
Skip to first unread message

Rosa Linda

unread,
Oct 26, 2014, 2:44:13 PM10/26/14
to ns-3-...@googlegroups.com
Hello,

Are the number of dropped/received/ transmitted frames calculated at the Mac layer? if not, could you please tell me where can I find information that is useful in such calculation in ns3.

Thank you.

Tommaso Pecorella

unread,
Oct 26, 2014, 5:20:50 PM10/26/14
to ns-3-...@googlegroups.com
It is all in the manual. Feel free to ask for clarifications after you have read it.

T.

Rosa Linda

unread,
Oct 28, 2014, 11:43:44 AM10/28/14
to ns-3-...@googlegroups.com
Thank Mr. Tom for your reply.

I found the statistical frame work in the manual very helpful and informative. However, I still need some clarification on how to get the number of transmitted frame at the mac layer.
I wrote the following code but I am still not able to get number of transmitted frame.

Ptr<PacketCounterCalculator> totalTx = CreateObject<PacketCounterCalculator>();
 totalTx->SetKey("wifi-tx-frames");
 
 Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (m_node->GetDevice(0));
 
 NS_ASSERT (dev != NULL);
 
 PointerValue ptr;
 dev->GetAttribute ("Mac",ptr);
 
 Ptr<AdhocWifiMac> mac = ptr.Get<AdhocWifiMac> ();
 
 NS_ASSERT (mac != NULL);
 
 mac->TraceConnectWithoutContext ("MacTx", MakeCallback(&PacketCounterCalculator::FrameUpdate, totalTx));

Please, is there any example that show how the mac tracecallback  can be used?

Thanks in advance for your cooperation.
 

Mehmet Ali Ertürk

unread,
Oct 28, 2014, 2:14:44 PM10/28/14
to ns-3-...@googlegroups.com
You can find a working simulation at simulator source folder examples/wireless/wifi-ap.cc  

28 Ekim 2014 Salı 17:43:44 UTC+2 tarihinde Rosa Linda yazdı:

Rosa Linda

unread,
Oct 29, 2014, 11:06:58 AM10/29/14
to ns-3-...@googlegroups.com
Thank you Mr. Erturk for your reply.

The example uses the information in the application layer. I would like to ask if there is another example that show how to get this mac information in the routing protocol.

Thank you.

Mehmet Ali Ertürk

unread,
Oct 29, 2014, 11:14:23 AM10/29/14
to ns-3-...@googlegroups.com
List of available trace sources; 


You can attach callback for almost all layers.
 

29 Ekim 2014 Çarşamba 17:06:58 UTC+2 tarihinde Rosa Linda yazdı:

Rosa Linda

unread,
Oct 29, 2014, 1:50:02 PM10/29/14
to ns-3-...@googlegroups.com
Thank you Mr.Erturk for your quick reply.

I have  some difficulties to deal with tracecallback from the routing. I tried to follow the example of wifi-ap.cc in the routing and this is the way that I access the mac from the routing then I place the callback. Please correct me if I have it wrong

Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (m_node->GetDevice(0));
NS_ASSERT (dev != NULL);
PointerValue ptr;
dev->GetAttribute ("Mac",ptr);
Ptr<AdhocWifiMac> mac = ptr.Get<AdhocWifiMac> ();
NS_ASSERT (mac != NULL);
 
mac->TraceConnectWithoutContext ("MacTx", MakeCallback (&ITSRoutingProtocol::DevTxTrace ()));

Mehmet Ali Ertürk

unread,
Oct 29, 2014, 4:19:28 PM10/29/14
to ns-3-...@googlegroups.com
You can also add callback using this syntax;  

  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacTx", MakeCallback (&DevTxTrace));
  Config::Connect ("/NodeList/*/DeviceList/*/Mac/MacRx", MakeCallback (&DevRxTrace));
  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxOk", MakeCallback (&PhyRxOkTrace));
  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&PhyRxErrorTrace));
  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&PhyTxTrace));
  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace));

Adding callback to the Mac/MacTx will trigger every tx in this layer, if you want to count transmitted packets you should use Phy/State/Tx and you can extract information   from packet header such as source and the destination addresses of the packets. 





29 Ekim 2014 Çarşamba 19:50:02 UTC+2 tarihinde Rosa Linda yazdı:

Rosa Linda

unread,
Oct 30, 2014, 2:45:40 PM10/30/14
to ns-3-...@googlegroups.com
Thank you Mr. Erturk for your cooperation. Your posts were very helpful. I tried the tracecallback and it is working fine and I am working right now on adding the counter.

Thanks again.
Reply all
Reply to author
Forward
0 new messages