IP: Internet Protocol
Overview
IP provides a connectionless datagram service : packets are not guaranteed to arrive correctly at their destination or even to arrive at all! This type of service is only as reliable as the service it is constructed on. But it is cheap. TCP builds a reliable delivery service based on IP datagrams.
Major IP issues included here are
addressing, datagram format, forwarding, fragmentation, and error reporting.
Addressing
Internetworking requires common addressing scheme, which must be uniform and therefore hardware-independent
IP specifies that each host has a unique 32-bit address.
Each router has two or more unique 32-bit IP addresses, one for each network it is attached to!
IP address consists of three parts: address class, prefix (network i.d.) and suffix (host i.d.).
Address Class
- Address classes are A, B, and C.
- Some networks (within the internet) will have many hosts, others will have few.
- When an organization obtains a network i.d. (prefix), it comes with a range of host i.d.'s.
- In order to efficiently utilize the full range of possible addresses, each class allows different numbers of hosts per network.
- Class A allows 224 hosts per network; it has 24 bit suffix. Leading IP bit is 0.
- Class B allows 216 hosts per network; 16 bit suffix. Leading IP bits are 10.
- Class C allows 28 hosts per network; 8 bit suffix. Leading IP bits are 110.
- How many bits does this leave for prefix, in each class?
Use this to calculate the maximum number of networks that can be assigned in each class.
Expressing IP addresses
- IP addresses expressed in dotted decimal notation.
- The 32 bits are partitioned into 4 parts of 8 bits each (octets).
- Each octet is expressed in decimal
- Octets are separated with the period (dot) character.
- Each of the 4 decimal values falls in the range 0-255.
- The possible range of addresses is 0.0.0.0 to 255.255.255.255, with some addresses reserved.
- The class of an IP address can be derived from the value of the first octet. Ranges are:
Class |
Binary Range |
Decimal Range |
A |
00000000 - 01111111 |
0-127 |
B |
10000000 - 10111111 |
128-191 |
C |
11000000 - 11011111 |
192-233 |
D |
11100000 - 11101111 |
224-239 |
E |
11110000 - 11111111 |
240-255 |
Classes D and E are reserved for multicast addresses future use, respectively.
Where does a network owner obtain IP addresses? From internet service provider. Ultimately, they come from central registry, to assure no conflicts. Ownership of the central registry has changed several times in recent years.
IP Addresses and Routers
- Network i.d. (prefix) is used by routers to forward a packet across the internet to its destination network.
- When packet reaches destination network, host i.d. (suffix) becomes relevant (internal routing to reach destination host, which may be on ethernet or other LAN).
Some special IP addresses
1. host i.d. is all 1's. packet delivered across internet to destination network, where it is then broadcast to all hosts.
2. host i.d. is all 0's. Identifies network. Cannot be a source or destination.
3. IP address is all 1's. broadcast throughout sender's physical network (used at startup).
4. IP address is all 0's. host uses it at boot time for protocol which determines its own address.
5. class A prefix all 1's (127 decimal). Loopback address. Use this to test network applications when you don't want packets to actually leave the host. Sender and receiver run on same host, and packets work down the sender's protocol stack and up the receiver's, all without leaving host.
If IP can address 2 billion machines, why are we running out of addresses?
- When organization gets network i.d., it controls all host i.d.s within that class.
- For classes A, B, and C, this is 224 , 216, and 28, respectively.
- Most large organizations need more than class C but fewer than class B.
- Most IP addresses are reserved but unused.
Solutions to IP Address Shortage
Stop-gap solution:
- Allocate contiguous blocks of C class networks, rather than a full B class.
- This is called CIDR (Classless InterDomain Routing).
- Routers had to be modified to accommodate this.
- Each routing table entry (one per network) was extended to contain a 32-bit mask.
- When packet arrives at router, its destination network i.d. is compared to each routing table entry as before, but not until that entry’s mask has been applied.
- Called classless because mask is applied to all addresses that come into the router, not just those from class C.
Long-term solution:
- IPv6. Address expanded to 128 bits.
- Still contains prefix and suffix, but not address classes.
- Addresses written in colon hexadecimal notation. This is 8 groups of 16-bit hex numbers, each group separated by colon. A sequence of multiple groups of 0's can be compressed to a double colon (::).
- For transition to Ipv6, IPv4 addresses will be put into last 32 bits of IPv6 address field and first 96 bits will be 0.
- Ipv6 allows 7 * 1023 IP addresses per square meter of the earth surface (water plus land). -- Andrew Tanenbaum, Computer Networks 3rd Edition.
Datagram Format
Consists of Header and Data. Minimum size is Header + 1 byte. Maximum size is 64K bytes. Header part is almost fixed-length. Datagram format is:
Field |
Length in Bits |
Description |
Version |
4 |
IP version number (4) |
Header Length |
4 |
length in 32-bit words |
Service Type |
8 |
tell router to optimize delay, throughput, reliability |
Total Length |
16 |
total datagram length (header+data) in bytes |
Identification |
16 |
datagram I.D. (for reassembling fragments) |
unused |
1 |
|
Don't Fragment |
1 |
whether or not datagram can be split up |
More Fragments |
1 |
0 if this is last fragment of datagram, else 1 |
Fragment Offset |
13 |
fragment I.D. within datagram (0-8191) |
Time To Live |
8 |
init to 255, decrement each hop, discard upon 0 |
Protocol |
8 |
transport layer protocol (e.g. TCP, UDP) |
Header Checksum |
16 |
sum 16-bit chunks of header using 1's complement |
Source IP Address |
32 |
|
Destination IP Address |
32 |
|
IP Options (optional) |
0-240 |
specify options for security, routing, timestamp,... |
Padding (optional) |
0-31 |
Enough to bring header length to 32-bit boundary |
Data |
1-64K bytes |
maximum actually is (64K - header length) bytes. |
Additional Notes on IP Header:
TTL may decrement to 0 if datagram caught in router cycle.
Checksum calculation: each 16-bit halfword of header (excluding checksum) is added using 1's complement, and 1's complement is applied to sum to form checksum. Receiver applies same algorithm to header including checksum, and result will be 0 if error-free. Note checksum changes on every hop because Time To Live will have changed!
Padding is only needed if IP Options are included. Otherwise, header length is fixed at 5 32-bit words.
Datagram Forwarding
When IP datagram arrives at router, router reads destination IP address, and looks up destination network (not host) in its routing table. Table entry contains destination network, 32-bit mask, and IP address of next-hop router (none, if this is last hop). Mask is applied to destination IP address (from datagram) as part of lookup. e.g.
for router table entry i
if (DestIP & Mask[i] == DestNet[i]) forward to NextHop[i];
The mask is part of
CIDR.
IP Subnet technique
IP subnet allows organization to utilize its class B network more effectively
Allows network to be partitioned internally but act like single network to outside world.
Does not affect routers outside the network.
Allows large organization to use class B IP network address more effectively.
Organization allocates subnets internally using subnet masks.
Distinguish from CIDR
ROUTING TABLE ENTRIES ARE OF TWO GENERAL TYPES:
1. External network, no host.
2. This network, host.
SUBNET ROUTING TABLE ENTRIES ARE OF THREE GENERAL TYPES:
1. External network, no host.
2. This network,other subnet
3. This network,this subnet,host.
Fragmentation
The Problem
IP datagram is transmitted across internetwork by variety of underlying physical protocols (e.g. ethernet, FDDI, ATM, etc).
At each hop, incoming datagram is
- Removed from the frame structure
- Destination is inspected and looked up in routing table
- Encapsulated into another frame
- Problem: different network technologies have different maximum frame payload length.
- If a router joins two dissimilar networks, the datagram arriving on a frame may be too long to fit into a single frame of the next-hop network.
The Solution
- Allow IP datagrams to be split up, or fragmented, into multiple smaller IP datagrams, so that each fragment can fit into a single frame.
- Router must:
- determine how many fragments are necessary,
- replicate the original IP header for each,
- modify the header fields devoted to fragmentation,
- fragment offset
is assigned a sequence number
- more-fragments
flag is set to 1 for all except last fragment
- transmit all fragments separately.
- Destination host (receiver) is responsible for reassembling original datagram!
- Datagram header info: datagram ID, fragment offset, and the more-fragments flag.
- Receiver starts timer when first fragment arrives and will discard all fragments of the datagram if any fragments have not arrived by the time the timer goes off.
Fragmentation in IPv6
- The original sending host is responsible for fragmenting, not the routers.
- This implies that the host must know the smallest max frame payload size along the datagram's path -- before sending it!
- A protocol has been established for it to learn this.
- The destination host reassembles, as before.
Error Reporting :
Internet Control Message Protocol (ICMP)
Protocol that IP uses to send error messages.
Error messages are themselves transmitted as IP datagrams.
Some error messages are:
- Source Quench
: router buffers are full so it tells sender to back off
- Time Exceeded
: datagram's TTL or fragment reassembly timer has expired -- notify sender.
- Destination Unreachable
: when router learns this, transmits message to sender
- Redirect
: tell sender to use a different route
- Fragmentation Required
: datagram too big but can't be fragmented -- drop it and notify sender.
The sender can learn about the network by cleverly crafting datagrams designed to trigger ICMP messages.
Example: traceroute
- tool to learn routing information
- send datagram with TTL of 1, and see who responds with "Time Exceeded".
- Send datagram with TTL of 2, and see who responds with "Time Exceeded"
- Etc.
Example: ping
- Uses ICMP Echo Request/Reply informational message.
- Sender transmits ICMP Echo Request to specified destination
- Awaits ICMP Echo Reply to determine whether that destination is reachable.
Example: determine smallest max. datagram length
- Send out exploratory IP datagram with "Don't Fragment" bit set
- See if you get an ICMP Fragmentation Required message in response.
- If not, size is OK.
- If so, try again with smaller size.
Related Home Pages:
notes | CSC 465 | Peter Sanderson | Computer Science | SMSU
Last reviewed: 15 April 1998
Peter Sanderson ( pete@csc.smsu.edu )