Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count packets for specific nodes #115

Open
philok93 opened this issue Sep 20, 2020 · 1 comment
Open

Count packets for specific nodes #115

philok93 opened this issue Sep 20, 2020 · 1 comment

Comments

@philok93
Copy link

Is your feature request related to a problem? Please describe.
I am trying to calculate some parameters for simulations. For example, I want to calculate the total number of packets sent by a node. The log file contains the following:

INFO  00:00:37.080 [send_packet:41] src:18 dst:22 len:79
INFO  00:00:40.987 [radio_read:97] RECV ret:16 src:18 dst:22 len:1 flags:1
INFO  00:00:37.110 [mac_handle_ack:76] ACK status:ACK_OK retries:2

[INFO: ICMPv6    ] Sending ICMPv6 packet to fe80::302:304:506:0, type 155, code 1, len 72
INFO  00:00:32.821 [send_packet:41] src:18 dst:0 len:79
INFO  00:00:36.702 [radio_read:97] RECV ret:16 src:18 dst:0 len:1 flags:1
INFO  00:00:32.826 [mac_handle_ack:76] ACK status:TX_ERR retries:0

In the calculations, I count the number of lines that contain send_packet or Sending ICMPv6 packet because it represents a ICMPv6 packet that was sent. However, when I see status:ACK_OK retries:2 or TX_ERR I don't know if I need to count retransmissions as extra packets sent.
My goal is to calculate the number of RPL control packets sent and the number of Application layer packet sent. Also, I need to calculate the retransmissions rate for the specific node. Is that possible using a cmd to calculate packets after simulation is finished?

Describe the solution you'd like
For example, If I provide log files I should be able to count the total packets sent and distinguish between RPL control packets and App layer packets. Retransmissions should also be good to calculate.

Describe alternatives you've considered
I calculated the total number by summing up the lines that contain Sending ICMPv6 packet + the retries number and deducted the number of lines that contain the status:TX_ERR word.

Thank you!

@nyrahul
Copy link
Collaborator

nyrahul commented Sep 21, 2020

There are two ways to get the statistics without having to parse the logs:

  1. Using the cmd_* OAM commands.
  2. Using the captured pcap files on per node basis.

Using OAM commands

❯ ./scripts/wfshell
wfsh# 
cmd_config_info        cmd_icmp_stats         cmd_nd6_stats          cmd_node_position      cmd_rtsize             cmd_tcp_stats          help                   path_upstream          
cmd_def_route          cmd_ipv6_stats         cmd_node_exec          cmd_route_table        cmd_set_node_position  cmd_udp_stats          native_shell           plot_network_graph     
cmd_get_udpapp_stat    cmd_mac_stats          cmd_node_osname        cmd_rpl_stats          cmd_start_udp          exit                   path_downstream  

To get icmp stats on node 1:

wfsh# cmd_icmp_stats 1
{ "icmp_stats": {
    "rcvd": "26",
    "sent": "22",
    "drop": "0",
    "typeerr": "0",
    "chkerr": "0"
}
}

To get mac stats on node 1:

wfsh# cmd_mac_stats 1
MCAST_PKTS: rx=22,tx=6
UCAST_PKTS: rx=99,tx=101,tx_succ=101,tx_fail=0,tx_attempt1=101,tx_attempt2=0,tx_attempt3=0

Similarly stats for IPv6/RPL/UDP/ICMP/TCP can be handled by the these OAM commands. These OAM commands depend on the stack's API for statistics. If the stack is not compiled with stats on then it wont work.

Using packet capture

This is a generic and guaranteed way to get the stats. Whitefield creates a pcap on per node basis in pcap/ folder.

To get all RPL packets sent/recv to the node ...
tshark -nr pcap/pkt-0-0.pcap -Y "icmpv6.type==155" | wc -l

To get all RPL packets sent from the node ...
tshark -nr pcap/pkt-0-0.pcap -Y "icmpv6.type==155 and ipv6.addr == fe80::ff:fe00:1" | wc -l

To get all UDP packets sent/recv to the node ..
tshark -nr pcap/pkt-0-0.pcap -Y "udp" | wc -l

Note that I am using node-specific pcap here .. hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants