Blackboard

Addressing Example

Sample Address: 128.171.10.206
Network Mask: 255.255.255.0 (bitwise inverse is 0.0.0.255)
Network Address: 128.171.10.0
Directed Broadcast Address: 128.171.10.255

The networks that a router is connected to.


The layers at which different devices operate

Note that the IP address belongs to an IP interface, not to the entire device.

A network with a single router, and the corresponding routing table

The last entry in the routing table represents the entire ethernet -- all possible ethernet addresses that are not found on this network have the same interface and next hop, and at least a cost of two (which is greater than for all the hosts on the directly attached network).

Making the above routing table smaller

All hosts on the directly attached network (with network address N and netmask M) in the above routing table can be represented by a single entry.
destination   mask   cost  interface   next hop
    N          M       1    eth0         *
For example, if the IP address of various hosts was 128.1.2.3, 128.1.2.4, 128.1.2.5, and the network mask 255.255.255.0, then the entry would be
destination   mask           cost  interface   next hop
128.1.2.0     255.255.255.0   1    eth0         *
Note that we cannot specify a single next hop in this case -- the router must have a convention for saying "the next hop is the address A that we are sending the packet to". For this example, I am using "*" to mean that.

We can also summarize the other routes, the ones to the entire rest of the internet. Here is an example:

destination   mask           cost  interface   next hop
              0.0.0.0          2    eth0         R1
Here, the address mask is all zeros. If we perform our usual computation to determine if the route matches, we will compare
Destination AND Maski to
Routei AND Maski

Both numbers are the result of ANDing with zero, and hence both numbers are zero, and therefore the two numbers match, and this is a valid route. This is a valid route, no matter what the destination address! In other words, this is a default route, and R1 is a default router for this host.

Here is the complete routing table for host E:

destination   mask           cost  interface   next hop
128.1.2.0     255.255.255.0   1    eth0         *
0.0.0.0       0.0.0.0         2    eth0         R1
We have entered an address of "0.0.0.0" as the destination of the second entry, but the actual number could be anything.

To summarize, when sending a packet to a host on the directly attached network, that host will have an IP address beginning with 128.1.2, and both routes will match. Since the first has lower cost, we will send the packet directly. When sending a packet to a host on a different network, only the second route will match, and we will send the packet to the default router.

We're almost there. Given any IP packet, we know where to send it to. The only question is, how do we send an IP packet on a directly attached network? In fact, if that network is an Ethernet, what Ethernet address do we send it to? If it is an ATM address, what ATM address do we send it to?


The sequence of fields in an ARP packet

The fields are described in the notes (last updated Friday, Oct 19th)

Sample IP header constructed in class

Everything should be correct except for the checksum.
0x45 0x00 0x01 0x04
0x00 0x00 0x00 0x00
0x60 0x11 0x00 0x00
0x80 0xAB 0x0A 0xCE
0x80 0x01 0x02 0x03

The little-endian way of writing the decimal value 260 would be
0x04 0x01
This is never used in the Internet protocols.

Writing big-endian values into a buffer

An incorrect way of writing a short to an IP buffer would be:
*((short *) (b + 2)) = length
A correct, more portable way of writing a short to an IP buffer would be:
*((short *) (b + 2)) = htons(length)
Note that in general we use a struct to represent the IP header, for example on uhunix2, struct ip in /usr/include/netinet/ip.h. But we will still need to use htons.
The protocol numbers used in IP are:
1 ICMP
6 TCP
17(0x11) UDP