IP
- Stallings lists the following functions IP performs
- Encapsulation
- We have seen this all along.
-
- Version number, (4 or 6 now, we are looking at 4 right now.)
- Length of the header in 32 bit words.
- DS/ECN differentiated services, congestion control
- Total packet length (data + header)
- Sequence number
- Flags, (don't fragment)
- Fragment offset (we will discuss this)
- TTL - a hop count
- Protocol (TCP, UDP, ICMP, ...)
- Header checksum
- Source/destination address
- Fragmentation/reassembly
- Fragmentation is sometimes required because
- Lower level networks don't support size of PDU we are sending
- Error control is sometimes easier
- More fair access to the network to all packets.
- Smaller buffers on receiving side.
- Possible checkpoint/recovery issues.
- But
- More overhead (headers/footers) is required
- More OS interruption
- More time spent processing smaller pdus
- We can set a don't fragment flag (in the header above)
- This indicates that the receiver has no buffer space and can't reassemble the packet.
- But it means packets will be discarded if they need to be fragmented.
- Fragmentation occurs at routers when required.
- Reassembly occurs at the destination.
- Reduces buffer requirements on routers.
- No need for all fragments to travel the same route.
- How to fragment:
- Use the following fields:
- ID - identifies a group of fragments that make up an higher level PDU
- Data length - length of local data
- Offset - position in main PDU of local data
- More flag - 0 -> last fragment, 1-> additional fragments.
- To fragment a PDU
- Create n new datagrams, copy the field header of source to all of them.
- Divide data field of source along 64 bit boundary's. The last need not be. Data + header must fit into new PDU data field.
- Set data length of all new datagrams appropriately
- Set more flag of all but last to be 1
- Set offset field approprately.
- Add offest to existing value (remember, we may be a fragement)
-
- To reassemle
- All fragements with the same ID are part of the same final PDU
- A buffer is allocated, and fragments are stored at the proper position as they arrive.
- This is computed by the more and offset flags.
- There is a time to live on a reassembled fragment
- If this is exceeded the partial PDU is discarded and the packet is declared lost.
- IP is connectionless
- Advantages:
- It is more flexible
- It is very robust
- TCP can supply these requriements.
- IP does not guarentee delivery.
- It does not guarentee ordered delivery
- IP does does report back if a PDU is discarded when possible. (ICMP)
- ICMP provides some level of flow coontrol.
- IP implements a packet lifetime via a ttl field.
- IP Does provide an addressing scheme:
- A 32 bit address, seperated into 4 octets.
- 147.64.242.52
- This contains a network part and a host part.
- Originally IPV4 provided classes.
- If the first bit is a 0, this is a class A netork.
- The next 7 bits are network bits.
- The last 24 bits are the host address.
- 224 = 16,777,216
- The standard netmask is FF.0.0.0
- Networks 1 to 126, 125 of these
- If the first two bits are 10 it is a class B network.
- The next 14 bits (16 total) are network information
- The last 16 bits are host information.
- 216 = 65,536
- The standard netmask is FF.FF.0.0
- Networks 128 to 191, 16K of these
- If the first three bits are 110 this is a class C network.
- The next 21 bits (24 total) are network
- The last 8 bits are host
- 28 = 256
- The standard netmask is FF.FF.FF.0
- Networks 192 to 223, 2M of these
- Other networks are reserved for
- Within each class is a non-routed network.
- Class A: 10.
- Class B: 172.16 -> 172.32
- Class C: 192.168.
- 127.0.0.0 is reserved for local loopback.
- CIDR
- The reason we didn't rou out of IPV4 network addresses when we though.
- Classless Inter-Domain Routing
- This redefines the netmask.
- Network addresses have an associated CIDR block length.
- This indicates the length of the network portion.
- EUP has 147.64 which is a class B.
- They have assigned 147.64.242 and 147.64.243 to CS
- Our netmask is FF.FF.FE (242 = 7216)
- Or 147.64.242/23
- This means 23 bits of the address are network part
- And 9 bits (or 512 machines) are host part.
- And the netmask with the IP to get network part
- And !netmask with IP to get host part.
- Look at ifconfig.