Lecture 21: Link and IP layers

Ethernet overview

A network is a group of computers (which I will also call nodes, hosts, or machines) that are connected together.

The physical medium that is used to connect them (e.g. twisted pairs of wires, radio waves, fiber-optic cable, etc) along with the rules for interpreting those signals (e.g. high voltage means 1) are referred to as the physical layer of the network. The physical layer gives a mechanism for transmitting a packet of bits from one host to another.

On top of the physical layer, the link layer defines how packets of bits should be sent and received. Ethernet is the most commonly used link-layer protocol.

Ethernet is a broadcast protocol: many hosts are connected to all other hosts. To send a packet, the sender first checks to see if the medium is in use. If not, it places the packet on the wire. It is possible that there are collisions if two hosts on the same network try to send at the same time. Senders are responsible for listening to the network to ensure that the packets they sent were received. If a collision is detected, the sender may retransmit after a delay. If the packet fails multiple times, it may be dropped. To detect collisions, ethernet packets contain a checksum.

Checking before transmitting is sometimes called "carrier sense (CS)"; the fact that hosts can communicate without mastering the bus is sometimes called "multiple access (MA)". Ethernet uses collision detection (CD), so Ethernet is therefore sometimes described as a "CSMA/CD" protocol.

Every ethernet packet contains a destination address; each receiver is responsible for discarding packets that are not destined for them. However, many network cards can be placed in promiscuous mode, where every packet is received whether it is addressed to the host or not.

End-to-end principle

Ethernet does not provide guaranteed delivery. If it does not detect a collision, it does not retransmit, even though the packet could have been lost for other reasons.

We could imagine building a more robust protocol by having the recipients respond with an acknowlegement. For example, we discussed a token ring, in which communication tokens are passed from one host to the next; if a message comes back to the sender without having been read, then the sender knows it was not received and can respond appropriately.

The end-to-end principle argues that adding additional complexity at this layer does not and cannot save other parts of the system from resolving the same problems. For example, even if the network can reliably deliver packets, a file transfer program will still have to implement some kind of acknowlegement to indicate that the file has been successfully written to disk. With this acknowlegement in place, acknowlegements at the ethernet layer become redundant.

Addressing within a network

Ethernet packets are addressed to a particular device on the network. Devices are identified by Media Access Control (MAC) addresses (also called a hardware address). MAC addresses are built in to every network device. They are typically written as a sequence of six two-character hex numbers, separated by colons, for example the MAC address for the ethernet card in my laptop is f0:1f:af:2a:7d:be.

Often it is useful to have logical addresses that are not bound to a specific device, but instead to a specific function. In addition to its fixed hardware address, a host can also have have an IP address assigned to it (more on the structure and function of IP addresses in the next lecture). IP addresses are typically written as a collection of four decimal numbers between 0 and 255, separated by periods (for example, my laptop's current IP address is 10.148.6.10).

To send a packet to a device having a specific IP address, a host must first find the MAC address of that device. To find this information, it uses the Address Resolution Protocol (ARP). It broadcasts an ARP request asking for the MAC address of the host with the desired IP address. The host having that IP address will respond with a packet containing its MAC address.

IP addresses can be assigned in a variety of ways. One is to configure each machine with its own IP address. This has the advantage of being completely decentralized; no central service needs to manage IP addresses. However, often you want a central service to manage IP addresses (to avoid collisions, for example, or to prevent having a network administrator from manually configuring each machine).

The Dynamic Host Configuration Protocol solves this problem: a specific host is designated as the DHCP server. When a new machine connects to the network, it broadcasts a DHCP request containing its MAC address. The DHCP server will respond to this request by sending back the host's IP address (and other configuration information).

Fragmentation

Network layer protocols (like IP) also have to deal with the fact that different networks have different transmission properties. In particular, different physical layers can have different maximum transmission units (MTUs): the maximium size of a single packet. This may mean that the IP layer needs to split large packets into smaller packets so that they can be sent along the next hop. Splitting packets is referred to as fragmentation.

Each IP header contains an identifier to indicate which original packet it is a fragment of, as well as its offset within the packet. When the end host receives a fragmented packet, it waits until it receives all fragments, and then reassembles them and delivers them to the next layer.

If it does not receive all fragments of a packet, the packet is discarded.