diff --git a/1.asc b/1.asc index 67518c9..3fff95e 100644 --- a/1.asc +++ b/1.asc @@ -4,7 +4,7 @@ IPv6 stands for Internet Protocol version 6, so the importance of IPv6 is implicit in its name, it’s as important as the Internet! The Internet Protocol (IP from now on) was intended as a solution to the need to interconnect different data networks, and has become the “de facto” standard for all kinds of digital communications. Nowadays IP is present in most devices that are able to send and receive digital information, not only the Internet. -IP is standardized by the IETF (Internet Engineering Task Force), the organization in charge of all the Internet standards, guaranteeing the interoperability among software from different vendors. The fact that IP is a standard is of vital importance, because today everything is getting connected to the Internet using IP. All common Operating Systems and networking libraries support IP to send and receive data. +IP is standardized by the IETF (Internet Engineering Task Force), the organization in charge of all the Internet standards, guaranteeing the interoperability among software from different vendors. The fact that IP is a standard, is of vital importance, because today everything is getting connected to the Internet using IP. All common Operating Systems and networking libraries support IP to send and receive data. As part of this "everything-connected-to-Internet" is the IoT, so now you know why you are reading this chapter about IPv6, the last version of the Internet Protocol. In other words, today, the easiest way to send and receive data is by means of the standards used in the Internet, including IP. The objectives of this chapter are: @@ -19,13 +19,13 @@ The objectives of this chapter are: === A little bit of History -ARPAnet was the first attempt of the US Department of Defense (DoD) to devise a decentralized network more resilient to an attack, while able to interconnect completely different systems. ARPAnet was created in the seventies, but it was in 1983 when a brand new protocol stack was introduced, TCP/IP. The first widely used network protocol version was IPv4 (Internet Protocol version 4) which paved the way to the civilian Internet. Initially only research centers and universities were connected, supported by the NSF (National Science Foundation), and commercial applications where not allowed, but when the network started growing exponentially the NSF decided to transfer its operation and funding to private operators, lifting the restrictions to commercial traffic. While the main applications were email and file transfer, it was with the development of the World Wide Web based on the HTML protocol and specifically with the MOSAIC graphic interface browser and its successors that the traffic really exploded and the Internet began to be used by the masses. As a consequence there was a rapid depletion in the number of IP addresses available under IPv4, which was not designed to scale to these levels. +ARPAnet was the first attempt by the US Department of Defense (DoD) to devise a decentralized network more resilient to an attack, while able to interconnect completely different systems. ARPAnet was created in the seventies, but it was in 1983 when a brand new protocol stack was introduced, called TCP/IP. The first widely used network protocol version was IPv4 (Internet Protocol version 4) which paved the way to the civilian Internet. Initially only research centers and universities were connected, supported by the NSF (National Science Foundation), and commercial applications where not allowed, but when the network started growing exponentially the NSF decided to transfer its operation and funding to private operators, lifting the restrictions to commercial traffic. While the main applications were email and file transfer, it was with the development of the World Wide Web based on the HTML protocol and specifically with the MOSAIC graphic interface browser and its successors that the traffic really exploded and the Internet began to be used by the masses. As a consequence there was a rapid depletion in the number of IP addresses available under IPv4, which was not designed to scale to these levels. In order to allow for more addresses, you need a longer IP address space (greater number of bits to specify the address), which means a new architecture, which means changes to most of the routing and network software. After examining a number of proposals, the IETF settled on IPv6, described in the January 1995 RFC (Request for Comment, the official IETF documentation naming) 1752, sometimes also referred to as the Next Generation Internet Protocol, or IPng. The IETF updated the IPv6 standard in 1998 with the current definition covered in RFC 2460. By 2004, IPv6 was widely available from industry and supported by most new network equipment. Today IPv6 coexists with IPv4 in the Internet and the amount of IPv6 traffic is quickly growing as more and more ISPs and content providers have started supporting IPv6. As you can see, the history of IP and Internet are almost the same, and because of this the growth of Internet is been hampered by the limitations of IPv4, and has led to the development of a new version of IP, IPv6, as the protocol to be used to interconnect all sorts of devices to send and/or receive information. There are even some technologies that are being developed only with IPv6 in mind, a good example in the context of the IoT is 6LowPAN. -From now on we will only center on IPv6. If you know something about IPv4, then you have half the way done, if not, don’t worry we will cover the main concepts briefly and gently. +From now on we will only focus on IPv6. If you know something about IPv4, then you have half the way done, if not, don’t worry we will cover the main concepts briefly and gently. === IPv6 Concepts @@ -36,7 +36,7 @@ In the following figure we represent the layered model used in the Internet. .Internet Protocol stack image::./images/1/image001.png[align="center"] -IPv6 sits in layer 3, called network layer. The pieces of data handled by layer 3 are called packets. Devices connected to the Internet can be hosts or routers. A host can be a PC, a laptop or a sensor board, sending and/or receiving data packets. Hosts will be the source or destination of the packets. Routers instead are in charge of packet forwarding, and are responsible of choosing the next router that will forward them towards the final destination. Internet is composed of a lot of interconnected routers, which receive data packets in one interface and send then as quick as possible using another interface towards another forwarding router. +IPv6 sits in layer 3, called network layer. The pieces of data handled by layer 3 are called packets. Devices connected to the Internet can be hosts or routers. A host can be a PC, a laptop or a sensor board, sending and/or receiving data packets. Hosts will be the source or destination of the packets. Routers instead are in charge of packet forwarding, and are responsible of choosing the next router that will forward them towards the final destination. Internet is composed of a lot of interconnected routers, which receive data packets on one interface and send then as quick as possible using another interface towards another forwarding router. ==== IPv6 packet @@ -44,17 +44,17 @@ The first thing you should know is what an IPv6 packet looks like. In the layere The Internet layers are: -* **Application**: Here resides the software developed by programmers, that will use network services offered by the network stack. An example is the web browser that opens a network connection towards a web server. Another example is the web server software that runs in a server somewhere in the Internet waiting to answer request from client's browsers. Examples of application protocols are HTTP and DNS. +* **Application**: Here resides the software developed by programmers, that will use network services offered by the network stack. An example is the web browser that opens a network connection towards a web server. Another example is the web server software that runs in a server somewhere in the Internet waiting to answer requests from client's browsers. Examples of application protocols are HTTP and DNS. -* **Transport**: Is a layer above the network layer that offers additional to it, for example, retransmission of lost packets or guaranteeing that the packets are received in the same order they were sent. This layer will be the one that shows a "network service" to the application layer, a service they can use to send or receive data. TCP and UDP are the most common transport protocols used in Internet. +* **Transport**: Is a layer above the network layer that offers additional services, for example, retransmission of lost packets or guaranteeing that the packets are received in the same order they were sent. This layer will be the one that shows a "network service" to the application layer, a service they can use to send or receive data. TCP and UDP are the most common transport protocols used in Internet. * **Network**: This is the layer in charge of the correct delivery of the data received from the transport layer to its destination, as well as the reception of the received data from the link layer at the data destination. Internet uses only one protocol in this layer, namely IP. Source and destination are identified by means of the IP addresses. -* **Link**: Link layer is in charge of sending and receiving frames, a collection of bytes sent from the network layer, in the realm of a local area network or LAN. It specifies the mecanism used to share the medium among diffrent nodes. This layer has its own addresses, which depend on the technology deployed. +* **Link**: Link layer is in charge of sending and receiving frames, a collection of bytes sent from the network layer, in the realm of a local area network or LAN. It specifies the mechanism used to share the medium among different nodes. This layer has its own addresses, which depend on the technology deployed. * **Physical**: This layer is in charge of the details of the electromagnetic signal, codifications, etc. needed for the digital information to go from one node to another. All physical media are included, both wired and wireless. -The following figure illustrates the idea that each of the layers described receive some bytes from the layer above and adds some specific information pertaining that layer to be processed in the receiving host. In the figure data originating at the application layer is sent to the physical layer of another node. +The following figure illustrates the idea that each of the Internet layers described previously, receive some bytes from the layer above and adds some specific information pertaining to that layer,which is processed in the receiving host. In the figure, data originating at the application layer is sent to the physical layer of another node. .Data flow in the protocol stack image::./images/1/image009.png[align="center"] @@ -64,7 +64,7 @@ The bytes sent and received in the IP packet follow a standard format. The follo .IPv6 Header image::./images/1/image002.png[align="center"] -First you have the *basic IPv6 header* with a fixed size of 40 bytes, followed by upper layer data and optionally by some extension headers, which will be described later. As you can see there are several fields in the packet header, providing some improvements as compared with IPv4 header: +First you have the *basic IPv6 header* with a fixed size of 40 bytes, followed by upper layer data and optionally by some extension headers, which will be described later. As you can see there are several fields in the packet header, providing some improvements when compared with IPv4 header: * The number of fields has been reduced from 12 to 8. @@ -72,7 +72,7 @@ First you have the *basic IPv6 header* with a fixed size of 40 bytes, followed b * The size of addresses increased from 32 to 128 bits. -The most important fields are the source and destination addresses. As you already know, every IP device has a unique IP address that identifies it in the Internet. This IP address is used by routers to take their forwarding decisions. +The most important fields are the source and destination addresses. As you already know, every IP device has a unique IP address that identifies itself in the Internet. This IP address is used by routers to take their forwarding decisions. IPv6 header has 128 bits for each IPv6 address, this allows for 2^128^ addresses (approximately 3.4×10^38^,i.e., 3.4 followed by 38 zeroes), whereas IPv4 uses 32 bits to encode each of the 2^32^ addresses (4,294,967,296) allowed. @@ -87,7 +87,7 @@ Several extension headers have been defined, as you can see in the previous figu * Optimize the processing of the packet, because with the exception of the hop by hop header, extensions are processed only by end nodes, (source and final destination of the packet), not by every router in the path. -* They are located as a "chain of headers" starting always in the basic IPv6 header, that use the field next header to point to the following extension header. +* They are located as a "chain of headers" starting always with the basic IPv6 header, that use the field *next header* to point to the following extension header. ==== IPv6 addressing @@ -117,20 +117,20 @@ image::./images/1/image010.png[align="center"] *IPv6 addresses notation rules* are: -* 8 Groups of 16 bits separated by “:”. +* 8 Groups of 16 bits separated by `:`. * Hexadecimal notation of each nibble (4 bits). * Non case sensitive. -* Network Prefixes (group of addresses) are written Prefix / Prefix Length, i.e., prefix length indicate the number of bits of the address that are common for the group. +* Network Prefixes (group of addresses) are written Prefix / Prefix Length, i.e., prefix length indicates the number of bits of the address that are common for the group. * Leftmost zeroes within each group can be eliminated. -* One or more all-zero-groups can be substituted by “::”. This can be done only once. +* One or more all-zero-groups can be substituted by `::`. This can be done only once. -The first three rules tell you the basis of IPv6 address notation. They use hexadecimal notation, i.e., numbers are represented by sixteen symbols between 0 and F. You will have eight groups of four hexadecimal symbols, each group separated by a colon ":". -The last two rules are for address notation compression, we will see how this works in the following. +The first three rules tell you the basis of IPv6 address notation. They use hexadecimal notation, i.e., numbers are represented by sixteen symbols between 0 and F. You will have eight groups of four hexadecimal symbols, each group separated by a colon `:`. +The last two rules are for address notation compression, we will see how this works in the following examples. Let's see some examples: @@ -140,14 +140,15 @@ Let's see some examples: 3) If we apply the fourth rule, allowing compression within each group by eliminating leftmost zeroes, we have: `2001:db8:4004:10:0:0:6543:ffd` -4) If we apply the fifth rule, allowing compression of one or more consecutive groups of zeroes using "::", we have: `2001:db8:4004:10::6543:ffd` +4) If we apply the fifth rule, allowing compression of one or more consecutive groups of zeroes using `::`, we have: `2001:db8:4004:10::6543:ffd` Care should be taken when compressing and decompressing IPv6 addresses. The process should be reversible. It's very common to have some mistakes. For example, the following address `2001:db8:A:0:0:12:0:80` could be compressed even more using "::". we have two options: a) `2001:db8:A::12:0:80` + b) `2001:db8:A:0:0:12::80` -Both are correct IPv6 addresses. But the address `2001:db8:A::12::80` is wrong, since it does not follow the last compression rule we saw above. The problem with this badly compressed address is that we can't be sure how to expand it, its ambiguous. We can't know if it expands to `2001:db8:A:0:12:0:0:80` or to `2001:db8:A:0:0:12:0:80`. +Both are correct IPv6 addresses. But the address `2001:db8:A::12::80` is wrong, since it does not follow the last compression rule we saw above. The problem with this badly compressed address is that we can't be sure how to expand it, it is ambiguous. We can't know if it expands to `2001:db8:A:0:12:0:0:80` or to `2001:db8:A:0:0:12:0:80`. ==== IPv6 network prefix @@ -158,7 +159,11 @@ Let's see some examples: 1) The network prefix `2001:db8:1::/48` (the compressed form of `2001:0db8:0001:0000:0000:0000:0000:0000`) indicates that the first 48 bits will always be the same (`2001:0db8:0001`) but that we can play with the other 80 bits, for example, to obtain two smaller prefixes: `2001:db8:1:a::/64` and `2001:db8:1:b::/64`. 2) If we take one of the smaller prefixes defined above, `2001:db8:1:b::/64`, where the first 64 bits are fixed we have the rightmost 64 bits to assign, for example, to an IPv6 interface in a host: `2001:db8:1:b:1:2:3:4`. -This last example allow us to introduce a basic concept in IPv6: * A /64 prefix is always used in a LAN (Local Area Network) *. *The rightmost 64 bits, are called the interface identifier (IID) because they uniquely identify a host's interface in the local network defined by the /64 prefix*. The following figure illustrates this statement: +This last example allow us to introduce a basic concept in IPv6: * A /64 prefix is always used in a LAN (Local Area Network) *. + +*The rightmost 64 bits, are called the interface identifier (IID) because they uniquely identify a host's interface in the local network defined by the /64 prefix*. + +The following figure illustrates this statement: .Network and Interface ID image::./images/1/image004.png[align="center"] @@ -177,7 +182,7 @@ The following are some other types of unicast addresses [RFC4291]: * *Link-local*: Link-local addresses are always present in an IPv6 interface that is connected to a network. They all start with the prefix `FE80::/10` and can be used to communicate with other hosts on the same local network, i.e., all hosts connected to the same switch. They cannot be used to communicate with other networks, i.e., to send or receive packets through a router. -* *ULA* (Unique Local Address) [RFC4193]: All ULA addresses start with the prefix FC00::/7, which in practice means that you could see `FC00::/8` or `FD00::/8`. Intended for local communications, usually inside a single site, they are not expected to be routable on the global Internet but used only inside a more limited environment. +* *ULA* (Unique Local Address) [RFC4193]: All ULA addresses start with the prefix `FC00::/7`, which in practice means that you could see `FC00::/8` or `FD00::/8`. Intended for local communications, usually inside a single site, they are not expected to be routable on the global Internet but used only inside a more limited environment. * *Global Unicast*: Equivalent to the IPv4 public addresses, they are unique in the whole Internet and can be used to send a packet from one site to any destination in Internet. @@ -192,7 +197,7 @@ The availability of a huge amount of addresses has allowed a new mechanism calle * *Statically*: You can decide which address you will give to your IP device and then manually configure it into the device using any kind of interface: web, command line, etc. Normally you also have to configure other network parameters like the gateway to use to send packets out of your network. -* *DHCPv6* (Dynamic Host Configuration Protocol for IPv6) [RFC3315]: A porting of the similar mechanism already available in IPv4. You need to configure a dedicated server that after a brief negotiation with the device assigns an IP address to it. DHCPv6 allows IP devices to be configured automatically, this is why it is named stateful address autoconfiguration, because the DHCPv6 server maintains a state of assigned addresses. +* *DHCPv6* (Dynamic Host Configuration Protocol for IPv6) [RFC3315]: A porting of the similar mechanism is already available in IPv4. You need to configure a dedicated server, which after a brief negotiation with the device assigns an IP address to it. DHCPv6 allows IP devices to be configured automatically, this is why it is named stateful address autoconfiguration, because the DHCPv6 server maintains a state of assigned addresses. * *SLAAC*: Stateless address autoconfiguration [RFC4862] is a new mechanism introduced with IPv6 that allows to configure automatically all network parameters on an IP device using the router that gives connectivity to a network. @@ -209,7 +214,7 @@ image::./images/1/image005.png[align="center"] 2) Both R1 and Host have a link-local address in their interfaces connected to the host's LAN, this address is configured automatically when the interface is ready. Our host creates it's link-local address by combining the 64 leftmost bits of the link-local's prefix (`fe80::/64`) and the 64 rightmost bits of a locally generated IID (`:3432:7ff1:c001:c2a1`). These link-local addresses can be used in the LAN to exchange packets, but not to send packets outside the LAN. -3) The hosts needs two basic things to be able to send packets to other networks: a global IPv6 address and the address of a gateway, i.e., a router to which send the packets it wants to get routed outside its network. +3) The hosts need two basic things to be able to send packets to other networks: a global IPv6 address and the address of a gateway, i.e., a router, to which it sends the packets which need to get routed outside its network. 4) Although R1 is sending RAs periodically (usually every several seconds) when the host get connected and has configured its link-local address, it sends an RS to which R1 responds immediately with an RA containing two things: @@ -221,7 +226,7 @@ image::./images/1/image005.png[align="center"] === Network Example -Following we show how a simple IPv6 network looks like, displaying IPv6 addresses for all the networking devices. +In the following, we show how a simple IPv6 network looks like, displaying IPv6 addresses for all the networking devices. .Simple IPv6 network image::./images/1/image006.png[align="center"] @@ -254,7 +259,7 @@ More information and installation instructions are available at https://www.wire .Wireshark Screenshot image::./images/1/image016.png[align="center"] -When you open Wireshark, there are four main areas, from top to bottom: menus and filters, list of captured packets, detailed information about the selected packet, including its full content in hexadecimal and ASCII. Online directly links you to the Wiresharks site, where you can find a handy user guide and information on the security of Wireshark. Under Files, you’ll find Open, which lets you open previously captured files,, and Sample Captures. You can download any of the sample captures through this website, and study the data. This will help you understand what kind of packets Wireshark can capture. +When you open Wireshark, there are four main areas, from top to bottom: menus and filters, list of captured packets, detailed information about the selected packet, including its full content in hexadecimal and ASCII. Help directly links you to the Wiresharks site, where you can find a handy user guide and information on the security of Wireshark and provides Sample Captures. Under Files, you’ll find Open, which lets you open previously captured files. You can download any of the sample captures through this website, and study the data. This will help you understand what kind of packets Wireshark can capture. The Capture section let you choose your Interface from the available ones. It’ll also show you which ones are active. Clicking details will show you some pretty generic information about that interface. @@ -276,7 +281,7 @@ image::./images/1/image018.png[align="center"] There are two methods to apply filters to the list of captured packets: -* Write a filter expression on the specific box and then apply it. Protocols can be specified (ip,ipv6, icmp, icmpv6), fields of a protocol (ipv6.dst, ipv6.src) and even complex expressions can be created using operators like AND (&&), OR (||) or the negation (|). +* Write a filter expression in the specific box and then apply it. Protocols can be specified (ip,ipv6, icmp, icmpv6), fields of a protocol (ipv6.dst, ipv6.src) and even complex expressions can be created using operators like AND (&&), OR (||) or the negation (|). .Wireshark Filter image::./images/1/image019.png[align="center"] @@ -438,7 +443,7 @@ Having a bidirectional communication with the IoT devices allows useful possibil * **Communication**: Send information to the IoT device, that can be displayed using some kind of interface. -IIPv6 is still being deployed all over the different networks that compose the Internet, which means that different scenarios can be found when deciding how to connect our network to the IPv6 Internet. Following are the three most common scenarios, in preferred order, being Native IPv6 connectivity the best choice. +IPv6 is still being deployed all over the different networks that compose the Internet, which means that different scenarios can be found when deciding how to connect our network to the IPv6 Internet. Following are the three most common scenarios, in preferred order, Native IPv6 connectivity being the best choice. * **Native IPv6 Connectivity**: This scenario applies when both the ISP providing connectivity to the Internet and the router(s) and networks devices used in our network support of IPv6. Native IPv6 means that the IPv6 packets will flow without being changed or tunnelled anywhere in its path from origin to destination. It is common to find what is called dual-stack networks, where both native IPv6 and native IPv4 are being used at the same time in the same interfaces and devices. This native IPv6 scenario covers both cases: IPv6-only and dual-stack. diff --git a/2.asc b/2.asc index 8a19900..7d00960 100644 --- a/2.asc +++ b/2.asc @@ -5,7 +5,7 @@ One of the drivers of the IoT, where anything can be connected, is the use of wi This wide adoption of wireless technologies allows increasing the number of connected devices but results in limitations in terms of cost, battery life, power consumption, and communication distance for the devices. New technologies and protocols should tackle a new environment, usually called Low power and Lossy networks (LLNs), with the following characteristics: . Significantly more devices than those on current local area networks. - . Severely limited code and ram space in devices. + . Severely limited code and RAM space in devices. . Networks with limited communications distance (range), power and processing resources. . All elements should work together to optimize energy consumption and bandwidth usage. @@ -48,7 +48,7 @@ It's also important to identify the characteristics of LoWPANs, because they wil . IEEE 802.15.4 defines several addressing modes: It allows the use of either IEEE 64-bit extended addresses or (after an association event) 16-bit addresses unique within the PAN (Personal Area Network). . Low bandwidth: Data rates of 250 kbps, 40 kbps, and 20 kbps for each of the currently defined physical layers (2.4GHz, 915MHz, and 868MHz, respectively). . Topologies include star and mesh. -. Large number of devices expected to be deployed during the lifetime of the technology. +. Large number of devices are expected to be deployed during the lifetime of the technology. Location of the devices is typically not predefined, as they tend to be deployed in an ad-hoc fashion. Sometimes the location of these devices may not be easily accessible or they may move to new locations. . Devices within LoWPANs tend to be unreliable due to variety of reasons: uncertain radio connectivity, battery drain, device lockups, physical tampering, etc. . Sleeping mode: Devices may sleep for long periods of time in order to conserve energy, and are unable to communicate during these sleep periods. @@ -118,6 +118,9 @@ As already said an IEEE 802.15.4 device could have two types of addresses. For e .EUI-64 derived IID image::./images/2/image003.png[align="center"] +.Global IPv6 Address derived from MAC Address +image::./images/2/image003a.png[align="center"] + . 16-bit short addresses: Possible but not always used. The IPv6 IID is formed using the PAN (or zeroes in case of not knowing the PAN) and the 16 bit short address as in the figure below. .IPv6IID diff --git a/3.asc b/3.asc index 8163717..fbe3baa 100644 --- a/3.asc +++ b/3.asc @@ -483,13 +483,13 @@ The `make login` command creates a connection to a `RE-Mote` or a `Z1` over the make login PORT=/dev/ttyUSB0 ---- -Note this will keep a connection open in the terminal, if you close the terminal the connection will be closed. Also, as programing the devices uses the USB port, if there is an existing connection open with the `make login` command, a programming attempt to the port will fail. +Note this will keep a connection open in the terminal, if you close the terminal the connection will be closed. Also, as programming the devices uses the USB port, if there is an existing connection open with the `make login` command, a programming attempt to the port will fail. You can also concatenate commands: [source, bash] ---- -make 01-hello-world.upload && make upload +make 01-hello-world.upload && make login ---- ==== diff --git a/images/2/image003a.png b/images/2/image003a.png new file mode 100644 index 0000000..84bd576 Binary files /dev/null and b/images/2/image003a.png differ