Post on 02-Jan-2016
2
IP Layer
• Defines a virtual network on top of difference kinds of hardware platform using IP address
• function of IP– route packet– fragmentation– handle type of service– send and receive error and control
message using ICMP
3
IP Attributes
• Handle data unit called IP datagrams
• - connectionless protocol doesn’t promise reliable delivery
• best effort delivery• packets maybe lost, out of seque
nce, or duplicated due the variou s reasons
5
IP Reframe
• IP will reframe the packet when A send data to B
Router
A BIP 172.28.80.96MAC 00:50:ba:49:9d:b9
IP 172.28.85.24MAC 00:02:7a:d2:b3:00
MAC destMAC srctypeIP srcIP dest
MAC destMAC srctypeIP srcIP dest
00:00:1a:2b:3c:4d00:50:ba:49:9d:b90x800172.28.80.96172.28.85.24
00:02:7a:d2:b3:0000:00:2a:3b:4c:5d0x800172.28.80.96172.28.85.24
Packet to router Packet from router
IP 172.28.80.1MAC 00:00:1a:2b:3c:4d
IP 172.28.85.1MAC 00:00:2a:3b:4c:5d
Change MAC address, IP address be the same
6
The Internet Protocol (IP)
AppTranspor
tNetwork
Link
TCP / UDP
IP
DataHdr
DataHdr
TCP SegmentIP Datagram
Protocol Stack
7
The Internet Protocol (IP)
Characteristics of IP• CONNECTIONLESS: mis-sequencing• UNRELIABLE: may drop packets…• BEST EFFORT: … but only if necessary• DATAGRAM: individually routed
A
R1
R2
R4
R3
BSource
DestinationD H
D H
•Architecture•Links•Topology
Transparent
8
The IP Datagram
Offset within original packet
Flags :3
vers : 4
TTL : 8
TOS : 8
Header Checksum : 16
hlen: 4
Total Length :16
Identification : 16 FRAG Offset : 13
Protocol :8
SRC IP Address : 32
DST IP Address : 32
(OPTIONS) (PAD)
<= 64 KBytes
Data..
0 15 16 31
20 Bytes
9
IP Header Details• Ver : version = 4• hlen : header length in 32 bit
words, hlen = 5 with no option• TOS : type of service , desired
quality of servicesPrec. D T R 0C
0 1 2 3 4 5 6 7
Bits if 0 if 10-2 Precedence3 Normal delay Low delay4 Normal throughput High throughput5 Normal reliability High reliability6 Normal cost Low cost7 Reserves
10
IP Header Details
• Total Length : max size datagrams include header (64KB)
• Identification , Flag, Fragmentation : use to segmentation and reassembly packet
• TTL : Time to Live, maximum number of routers through with the datagrams may pass (hop count)– decrease at each router to prevent forever looping– normally set to 30– if TTL == 0 discard and send ICMP TTL exceeded to
source IP
11
IP Header Details
• Protocol : higher level protocol that provi de data
– 1 = datagrams carries an ICMP messages– 6 = datagrams carries an TCP segments– 17 = datagrams carries an UDP datagrams
• Header checksum : 16 bits one’s comple ment, note that there is no data checksu
m
12
IP Header Details
• Source address : 32 bits IP source address
• Destination address : 32 bits IP destination address
• Option and Padding : (maximum 40 bytes) addition information to control functions such as routing and security
13
Type of Service in some Internet Protocol
Application D T R C
TELNET 1 0 0 0 Minimize delayFTP control data
10
01
00
00
Minimize delayMaximize throughput
Meaning
From RFC 1349
TFTP 1 000 Minimize delaySMTP command phase data phase
10
01
00
00
Minimize delayMaximize throughput
DNS UDP query TCP query zone transfer
SNMP Maximize reliability0 0 1 0
100
001
000
000
Minimize delayMaximize throughput
14
Routing• Process of choosing a path over which to
send datagrams• IP routes packet by looking at the IP
network number• Routing components
– determine what path are available– selecting the best path for a particular
purpose– using those paths to reach other network
• devices which perform routing are routers(Historically call IP gateways)
15
Routing Table
• Every router contains a routing table of the network numbers
• The table record– Which connection can be used to
reach a particular network– plus some indication of the
performance or cost of using connection
17
Routing Protocol
• Routing protocol manages and updates routing table on each network node
• UNIX often implemented using one of the two daemons– routed : basic routing daemon for interior
routing, normally with RIP– gated : sophisticated daemon for interior
and exterior routing, with additional protocol such as OSPF, BGP
18
Fragmentation• Fragmentation : processed used by IP to
reduced size of datagram that are too long for network interface MTUe.g. fragment 2000 bytes to Ethernet MTU 1500 Bytes
• fragmentation should be reassembled at final destination (expensive process)
• how?– each fragment has it own header– each fragment carries the same 16 bits
identification header– each fragment must be aligned with eight-octet
boundary
19
Fragmentation Flag• Identification number
– 16 bits integer value used to identify all fragments– This ID is not a sequence number
• Flags : 3 bits control fragmentation
• Fragment offset : indicate the distance of fragment data from the start of original datagram, measure in 8 octets unit
R DF MF
0 = last fragment1 = more fragment
0 = may fragment1 = don’t fragment
Reserve must be 0
20
Fragmentation
…….. 232 0 0 0..2000
...2321 0 0 .. 1479
...23201851480 .. 2000
original
Ethernet with MTU 1500
20 bytes 20 bytes
Other headeridentflagsoffset data
Identification numberMore fragment
Post 0
Last fragment
Post 185 * 8 = 1480
21
Problem in fragmentation• The end node has know way of knowing how
many fragments there be. The end node has to manage enough buffer space to handle reassembly process.
• If any fragments lost, all datagram must be discarded
• End node starts a timer when received the first fragment, if any fragments fails to alive(usually 30 sec), all datagrams must be discarded
• Since the IP service is connectionless. No attempt is made by IP to recover these situations, though ICMP error massage may be generated
22
Avoiding Fragmentation• For datagrams with in the same physical network, the
MTU is known. TCP/UDP then use the MTU to limit the message size pass to IP, message will never be fragmented.
• For datagram pass to difference network, unknown MTU.
• Standard recommend that all networks supporting TCP/IP have an MTU of at least 576 bytes
512 bytes data + 20 bytes TCP header + 20 bytes IP header with options to guarantee that a packet of 576 bytes or less is never fragmented