IP : Internet Protocol

Download Report

Transcript IP : Internet Protocol

IP : Internet Protocol
Computer Network System
Sirak Kaewjamnong
1
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
2
IP Attributes
•
•
•
•
Handle data unit called IP datagrams
connectionless protocol-doesn’t promise reliable delivery
best effort delivery
packets maybe lost, out of sequence, or duplicated due the
various reasons
3
IP Encapsulation
With Ethernet frame
datagram
Ethernet Header IP Header
Data
4
IP Reframe
• IP will reframe the packet when A send data to B
IP 172.28.80.1
MAC 00:00:1a:2b:3c:4d
MAC dest
MAC src
type
IP src
IP dest
00:00:1a:2b:3c:4d
00:50:ba:49:9d:b9
0x800
172.28.80.96
172.28.85.24
IP 172.28.85.1
MAC 00:00:2a:3b:4c:5d
Router
Packet to router
A
IP 172.28.80.96
MAC 00:50:ba:49:9d:b9
MAC dest
MAC src
type
IP src
IP dest
00:02:7a:d2:b3:00
00:00:2a:3b:4c:5d
0x800
172.28.80.96
172.28.85.24
Packet from router
B
IP 172.28.85.24
MAC 00:02:7a:d2:b3:00
Change MAC address, IP address be the same
5
The Internet Protocol (IP)
Protocol Stack
App
Transport TCP / UDP
IP
Network
Link
Data
Data
Hdr
Hdr
TCP
Segment
IP
Datagram
6
The Internet Protocol (IP)
Characteristics of IP
• CONNECTIONLESS:
• UNRELIABLE:
• BEST EFFORT:
• DATAGRAM:
Source
D
A
D
mis-sequencing
may drop packets…
… but only if necessary
individually routed
R2
H
R1
R3
R4
H
B
Destination
•Architecture
•Links
•Topology
Transparent
7
The IP Datagram
15 16
0
vers : hlen:
4
4
TOS : 8
Total Length :16
Flags
:3
Identification : 16
20 Bytes
TTL : 8
31
Protocol :8
Offset within
original packet
FRAG Offset : 13
Header Checksum : 16
SRC IP Address : 32
<= 64 KBytes
DST IP Address : 32
(OPTIONS)
(PAD)
Data
.
.
8
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 services
0 1 2 3
Prec.
Bits
0-2
3
4
5
6
7
4
D
5
T
6
R
7
C
0
if 0
if 1
Precedence
Normal delay
Low delay
Normal throughputHigh throughput
Normal reliability High reliability
Normal cost
Low cost
Reserves
9
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
10
IP Header Details
• Protocol : higher level protocol that provide 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 complement, note that
there is no data checksum
11
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
12
Type of Service in some Internet Protocol
Application
D
T R
C
Meaning
TELNET
FTP
control
data
TFTP
SMTP
command phase
data phase
DNS
UDP query
TCP query
zone transfer
SNMP
1
0
0
0
Minimize delay
1
0
1
0
1
0
0
0
0
0
0
0
Minimize delay
Maximize throughput
1
0
0
1
0
0
0
0
Minimize delay
Maximize throughput
1
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
Minimize delay
Maximize throughput
Maximize reliability
Minimize delay
From RFC 1349
13
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)
14
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
15
Routing Table Form
Routing table form
• network , gateway, other
16
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
17
Fragmentation
• Fragmentation : processed used by IP to reduced size of
datagram that are too long for network interface MTU
e.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
18
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
0 = may fragment
0 = last fragment
1 = don’t fragment
1 = more fragment
R DF MF
Reserve
must be 0
• Fragment offset : indicate the distance of fragment data from the
start of original datagram, measure in 8 octets unit
19
Fragmentation
original
Other header
ident flags offset
……..
232
20 bytes
Ethernet
with MTU 1500 ... 232 1 0
0
0
data
0..2000
20 bytes
0 .. 1479
Identification number
More fragment
Post 0
... 232 0 185 1480 .. 2000
Last fragment
Post 185 * 8 = 1480
20
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
21
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
22