The network layer is the transport segment from the sending to the receiving host.

It is most notable for being the layer containing IP (the Internet Protocol).

Layer-3 packets are datagrams which encapsulate segments

Network layer functions

  • forwarding - moving packets from a router’s input link to the appropriate output link
  • routing - determinging the route taken by packets from source to destination

Data Plane, Control Plane

The dataplane is a local per-router function and determines how datagram arriving on the router’s input port should be forwarded to the output port. The control plane is network-wide logic, it determines how the datagram is routed among routers along end-to-end paths from the source host to the destination host.

IP

The IP datagram format can be found online.

  • IP addresses are 32-bit numeric identifiers associated with each host or router interface

Subnets

Subnets are device interfaces that can physically reach each other without passing through an intervening router.

IP addresses consist of a subnet identifier and a host identifier.
The subnet mask defines which bits are used for the subnet id, the remaining bits are used for the host id.

CIDR

classless interdomain routing defines an address with a subnet portion of arbitrary length, address format is a.b.c.d/x where x indicates the number of bits used for a subnet

DHCP

Dynamic Host Configuration Protocol is used by hosts to get an IP address on a network.

  • host broadcasts a DHCP discover message to locate the DHCP server (optional)
  • DHCP server responds with a DHCP offer message (optional)
  • host requests an IP address (DHCP request message)
  • DHCP server sends address (DHCP ack message)

DHCP can return more than just the allocated IP address on the subnet! DHCP is also used to discover:

  • the first-hop router’s address
  • name and IP address of a DNS server
  • network mask

DHCP is a protocol that uses UDP.

Where do IP addresses come from

ICANN assigns a large block of them to an ISP and the ISP then assigns individual addresses or smaller blocks of them to organisations/individuals

NAT

Network address transition allows many devices on a LAN to share a single IPv4 address