ObjectivesWe 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 IPv6Internet 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 AddressesAn 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:
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 FieldsSimilar to IPv4, an IPv6 address is split into 2 field:
ExperimentsDerive an IPv6 AddressIn 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:
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:
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:
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):
We will now get a packet capture containing some of the NDP packets to see them in action:
Challenge
Why doesn't it work? Consider setting up packet captures on h1 and h3 to understand the problem. Your ReportAfter 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
|