Internet Protocol (IP)
Internet Protocol (IP)
- Designed with internetworking in mind.
- Datagram-based (connectionless)
Datagram format
The header contains| bits |
contents |
| 4 |
version # (of the protocol) |
| 4 |
header length (in 32-bit words) |
| 8 |
type of service (priority, delay,
throughput, reliability) |
| 16 |
total length (in bytes; limits datagram
to 216 bytes; usually <= 1500) |
| 16 |
identification (used for fragmentation) |
| 1 |
unused |
| 1 |
DF (don't fragment) |
| 1 |
MF (more fragments) |
| 13 |
fragment offset |
| 8 |
time to live |
| 8 |
protocol (TCP, UDP) |
| 16 |
header checksum |
| 32 |
source address |
| 32 |
destination address |
| options |
IP Addressing
- IP provides a uniform addressing scheme
- IP addresses are logical, not physical addresses
- Addresses are supplied by software, not hardware
- Global internet addresses are obtained from ISPs (Internet Service
Providers) which coordinate among themselves
- In a private intranet, local admins can assign whatever addresses they want
- IPv4 addresses are 32 bits, normally written in dotted-decimal notation; for example, 132.101.10.4, which in hex would be 0x84650A04.
- Addresses are two-dimensional, consisting of (network #, host #)
- A router has several IP addresses, one for each link
- Hosts normally have a single IP address, but can be multihomed (more
than one IP address) for reliability or performance
Question: In an IP address, how many bits are used for the network number and how many for the host number?
The answer is not simple.
The original IP addressing scheme was based on classes. The bit format was different for each class, as shown below:
| class |
class prefix |
network |
host |
| A |
0 |
7 bits |
24 bits |
| B |
10 |
14 bits |
16 bits |
| C |
110 |
21 bits |
8 bits |
| D |
1110 |
multicast
address |
|
| E |
11110 |
reserved
for future use |
|
Special cases
| 0.0.0.0 |
this host |
| (000...0, host) |
host on this network |
| 255.255.255.255 |
broadcast on this physical network |
| (network, 111...1) |
broadcast on given network |
| 127.x.y.z |
loopback |
How does this addressing structure affect routing?
Router tables contain entries in the form
| IP address |
next hop |
| (network #, 0) |
--- |
| (this network, host #) |
--- |
A router needs to know how to forward to each network and to hosts on its
own network. This is the hierarchical routing scheme we described earlier.
(The division into network number, host is determined by the class.)
Subnets
Problem: There are no network sizes between B and C A class B network has 65000 hosts, a class C network has 254 hosts.
65000 hosts would require local routers to have very large routing tables.
A subnet represents an extra hierarchical layer
One network (as far as the outside world is concerned) is divided into
several subnetworks.
So a class B address consists of (10, network #, subnet #, host #)
Router tables contain entries in the form
| IP address |
next hop |
| (network #, 0, 0) |
--- |
| (this network, subnet #, 0) |
--- |
| (this network, this subnet, host #) |
--- |
This scheme adds another level to the hierarchical routing structure. A
router on subnet x needs to know how to forward packets to hosts on x, to
subnets of its own network, and to other networks.
The division into (subnet,host) is done locally, and is therefore not uniform throught the Internet.
The subnet mask is assigned locally. For example, if the subnet
mask is 255.255.255.0, then IP addresses are often written in the form 132.101.10.4/24,
with the "24" indicating the number of bits in the subnet mask.
Classless Addressing
Problem: We are running out of IP addresses. Every organization with more than 254 hosts (or which expects to grow to that number) needs at least a class B address for its network. There are only 8192 class B addresses.
We need a way to assign blocks of addresses in sizes between 254 and 65536.
So we now have Classless Interdomain Routing (CIDR), which generalizes the idea of subnet addressing.
- The boundary between network number and host number can be anywhere within the 32-bit IP address.
- An IP address may be written in the form a.b.c.d/x, where x is the number of bits in the network number, also known as the network prefix or address mask.
- This allows more flexibility in the assigning of blocks of addresses. For example, a block of 2048 addresses (211) from 194.24.16.0/21 to 194.24.23.255/21. (Block sizes are powers of 2.)
- The remaining bits of the IP address may still be split into (subnet,host) if the organization chooses to do so.
Q: How does this addressing structure affect routing? In particular, when it reads a packet's destination address, how does a router know what the network prefix is?
A: It doesn't. Forwarding is handled as follows:
- Router table entries contain an IP address and an address mask.
- The router attempts to match the incoming IP address with a (address,
mask) entry in the table.