Last days I have been working on a interesting project, a part of this project covered generating traffic for IPv4 and IPv6. The protocol used for this is ICMP and ICMPv6. I have chosen a very naive approach and belived and thought that can be done in no time. It's a no brainer.

Since my favourite tool of choice is CLI, my first thought has been hey I know a cool software which I know since over 1 decade let's take nmap.

Nmap ships a tool named nping I have written a simple script for generating ICMP traffic each for each minute:

#!/bin/sh
# generate random integer between 20-500 including both for nping
COUNT=$(( RANDOM % (500 - 20 + 1 ) + 20 ))

# generate random integer between 64-1400 including both
PAYLOAD=$(( RANDOM % (1472 - 64 + 1 ) + 64 ))

# ping the IPv4 target
    nping --icmp --df --delay 100ms 1.1.1.1 -c $COUNT --data-length $PAYLOAD -H

That was an easy exercise, now let's copy that and do that same for ICMPv6. Now to the interesting part. Here is a easy output from a linux host command line

user % nping -6 --icmp fc00::1

 
Starting Nping 0.6.40 ( http://nmap.org/nping ) at 2017-07-18 15:41 UTC Error opening capture device eth0 --> Error compiling our pcap filter: expression rejects all packets

There is not much to explain about the upper command line it says:

nping using the IPv6 Protocol ,and ICMP the host FC00::1

Something basic had to be wrong. Now let's read the manual about IPv6 and ICMP echo types. RFC4443 Section 4.1. It says:

4.1.  Echo Request Message

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Type      |     Code      |          Checksum             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Identifier          |        Sequence Number        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Data ...
+-+-+-+-+-

IPv6 Fields:

Destination Address

Any legal IPv6 address.

ICMPv6 Fields:

Type           128

Code           0

Identifier     An identifier to aid in matching Echo Replies
                  to this Echo Request.  May be zero.

Setting explicit icmp-type and icmp-code arguments for this ICMP request should be enough:

user % nping -6 --icmp icmp-type 128 --icmp-code 0 fc00::1

  Failed to resolve given IPv6 hostname/IP: icmp-type. Note that you can't use '/mask' or '[1-4,7,100-]' style ranges for IPv6. Error code -3: Temporary failure in name resolution Execution aborted. Nping needs at least one valid target to operate.

This error says it does not recognize a valid IPv6 address. The careful reader will see what this error says. It says it uses ICMP and the RFC says ICMPv6. Hey, Let's try with using the current version:

user % nping -6 --icmp fc00::1

  Starting Nping 0.7.50 ( https://nmap.org/nping ) at 2017-07-19 15:24 CEST libnsock nsock_pcap_set_filter(): Error compiling pcap filter: expression rejects all packets Error opening capture device eth0

Same error with the newest version of Nping. What I have been doing wrong?

A quick visit in the IRC channel and a research of the bugtracker brought the something to light I would not belive it would be true:

FIXME and TODO comments in source files

...
libnetutil/PacketParser.cc:1580:               * TODO: Implement these ICMPv6 types. */
...

ICMPv6 is not implemented in in nping.

Trying out other tools following things have been discovered,

  • ostinato IPv6 extended headers support are not implemented yet.
  • hping IPv6 support not implemented at all.

The only tools that seems to support ICMPv6 by now and are suited for the command line:

  • scapy. Now scapy tool comes with the heavy baggage of python
  • fping Another tool that also supports ICMPv6 fully.