1
votes

I am working on creating a traceroute service for Android, and since Android does not come with a built in traceroute command, I am implementing one using adb shell ping iteratively with increasing TTL values.

This is a sample of the request/response:

    //Sample shellCommand: /system/bin/ping -c 1 -t 8
    Runtime.getRuntime().exec(shellCommand + DESTINATION_URL);

PING opf-www.google.com (xxx.xxx.xxx.xxx) 56(84) bytes of data.
--- opf-www.google.com ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

  1. I want to know how to decipher "56(84) bytes of data". What is 56 and 84 here?

  2. I want to analyse the amount of data used by traceroute, and am using TrafficStats class to do so:

    int UID = myUid();
    long mStartRX = TrafficStats.getUidRxBytes(UID);
    long mStartTX = TrafficStats.getUidTxBytes(UID);
    new TracerouteTask().run();
    long rxBytes = TrafficStats.getUidRxBytes(UID)- mStartRX;
    long txBytes = TrafficStats.getUidTxBytes(UID)- mStartTX;
    

Using this, I always receive a value of 0 for rxBytes, i.e no. of bytes received. Why is this the case? We receive an ICMP TTL exceeded packet.

1

1 Answers

1
votes

I found the answer, updating in case this helps someone in the future :)

The 56(84)in indicates that the payload of "dummy data" contained in the ICMP message is 56 bytes and when combined with the 28 bytes of ICMP header data that tells the message where to go, the total packet size is (84) bytes.