alt text 

Experiment II: Explorations in the IPv6 Address Space

Ahmet Sekercioglu and Leon Seng

Objectives

We will learn about IPv6 addresses, some basic methods for manipulating IPv6 addresses for IPv6 network programming, and a couple of interesting self-organization mechanisms built-in IPv6 networks. We will also learn about bit manipulation which will be useful when you start writing your reliable file transfer project.

About IPv6

Internet Protocol version 6 (IPv6) is the most recent IP protocol designed with the intention for the eventual replacement of IPv4 (probably will never happen though), largely due to the IPv4 address exhaustion problem, as IPv4 can only provide up to 2^32 (~ 4 billion) unique IP addresses. It also brings some additional benefits such as: multicasting (specifically anycast), autoconfiguration of IP addresses (especially important for the huge number of devices that exist in the IoT world), and simpler IP headers (multiples of 32 bits) for faster packet processing.

IPv6 Addresses

An IPv6 address is 128 bits long. An IPv6 address looks like this: 2001:0000:0000:0000:00be:0000:0000:0856, a string represented by eight groups, separated by colons, of four hexadecimal digits. To make it more human readable, a double-colon :: short hand has been introduced to replace consecutive octets of 0000 (this can be done once per IPv6 address, why?). Leading zeros in each octet can also be dropped. Hence, the above IPv6 address above can be shortened as 2001::be:0000:0000:856.

Stateless Address Autoconfiguration (SLAAC)

A network interface can either have a fixed IPv6 address set by the user, or have its IPv6 address configured automatically using one of the following two methods:

  • Dynamic Host Configuration Protocol (DHCP): Similar to how it is done in the IPv4 world. This requires a DHCP server (a router would do this task for example) to allocate the IP address from a pool of addresses.

  • Stateless Address Autoconfiguration (SLAAC): Uses EUI-64 (64-bit extended unique identifier) to determine a globally unique address based on the MAC address of the network interface.

In the IoT (the Internet of Things) universe, DHCP approach will not work because of the huge number of the “things”, so devices themselves will create their IP addresses by using SLAAC.

IPv6 Network and Host Address Fields

Similar to IPv4, an IPv6 address is split into 2 field:

  • Network address identifies a network segment. All hosts in a segment will share the same network bits. If undefined, the address block fe80::/10 will be used as defined in the IPv6 standard.

  • Host bits uniquely identify each host in the network. SLAAC method allows the derivation of the host bits using the EUI-64 process by using the MAC address of the network interface.

Experiments

Derive an IPv6 Address

In this experiment we will write the routine to derive the IPv6 address on a host interface using SLAAC. We will be using this simple network of three hosts connected via an Ethernet switch:

As the EUI-64 format requires a 64-bit interface ID and a 64-bit prefix, we will be extending the link-local network prefix to the first 64 bits of the IPv6 address, making our network address fe80::/64. Let's start:

  1. Copy the Mininet script: 3hosts_1switch_net.py

  2. Start the Mininet network: sudo python 3hosts_1switch_net.py

  3. Open up the terminal of h1: xterm h1

  4. Note the MAC address for the h1-eth0 interface: ifconfig h1-eth0

We will use this MAC address to test the validity of the operation of our script.

Now, write a Python script that accepts a MAC address as an argument, and prints the generated IPv6 address. We will call the script like this:
    python gen_ipv6_addr.py aa:bb:cc:dd:ee:ff

You may like to use the following script as your starting point:

import sys

def process_args():
    print('I see:', len(sys.argv), 'arguments.')
    print('Argument list:', sys.argv)
    mac_addr = sys.argv[1]
    print('MAC address:', mac_addr)
    print('Type of the argument:', type(mac_addr)) # Be careful! It is not a
                                                   # binary number.
    print('Leftmost nibble:', mac_addr[0])

if __name__ == '__main__':
    process_args()

We think that this Python bit operations example page could be useful.

The steps to derive the host bits and generate an IPv6 address are:

  1. Split the 48-bit MAC address into two 24-bit halves.

  2. Insert a 2-byte/16-bits ff:fe hexadecimal number in between the two halves of the MAC address, resulting in a 64-bit long address.

  3. Flip the 7th most significant bit of the 64-bit address. The result will be the host bits of the IPv6 address.

  4. Combine the network address fe80::64 and the host address derived in the previous step.

As a test, if you feed the MAC address of the h1-eth0 interface to your script, it should generate the IPv6 address of the h1-eth0 interface.

Neighbor Discovery Protocol (NDP)

Once an IP address has been generated, how does the host ensure that it is unique in the network? IPv6 introduced NDP, which replaces IPv4's Address Resolution Protocol (ARP).

There are 5 packet types in NDP (we discuss NDP in our IPv6 lecture):

  1. Router Solicitation (Type 133) - sent by nodes to locate routers in the network

  2. Router Advertisement (Type 134) - periodically sent by routers to advertise their presence in the network and other network information (e.g. network address)

  3. Neighbor Solicitation (Type 135) - sent by nodes to determine the link layer address of a neighbor, or to verify that a neighbor is still reachable via a cached link layer address

  4. Neighbor Advertisement (Type 136) - used by nodes to respond to a Neighbor Solicitation message, usually contains the link layer address of the nodes

  5. Redirect (Type 137) - sent by routers to inform hosts of better path to reach a certain destination

We will now get a packet capture containing some of the NDP packets to see them in action:

  1. Open up the terminal of h1, and clear the IPv6 neighbour table on h1:
       ip -family inet6 neigh flush any

  2. Verify that the table is empty:
       ip -6 neigh show

  3. Open up the terminal of h2, get the IPv6 address of h2-eth0 interface:
       ifconfig h2-eth0

  4. Start a packet capture on h2 for IPv6 packets:
       tcpdump -i h2-eth0 -vv -s0 ip6 -w ./ipv6.pcap

  5. Back on h1, ping the IPv6 address of h2-eth0 interface:
       ping -6 -I h1-eth0 <IPv6 address of h2-eth0>

  6. On h2, stop the packet capture operation by pressing CTRL+C. This should leave a file ipv6.pcap in the current directory.

  7. Open the pcap file with Wireshark and explain what you observe.

Challenge

  1. Open up the terminal of h1.

  2. Try pinging h3.

Why doesn't it work? Consider setting up packet captures on h1 and h3 to understand the problem.

Your Report

After finishing your experiments, you will need to prepare a short (maximum two pages, 10 pt Times-Roman font) report summarizing the key points you have learned in this exercise.

Please convert your report to PDF (no other formats will be accepted), zip your report with all the Python code you have written for the experiment, and upload all as a single zip file to the unit's Moodle site before the due date (we will post the deadlines at the unit's Moodle site).

References


Ahmet's Home