You are on page 1of 51

Lecture 3:

Internet Layer
HEDSPI Project
Hanoi University of Technology
by
Ngo Hong Son

This course materials contains charts and texts provided by Keio University, Japan
1
Content
 Introduction of Internet Protocol
 IP address
 IP packet format
 Internet Control Message Protocol - ICMP

2
Introduction to
Internet Layer
Basic concepts
Store-and-forward mechanism
Internet Protocol

3
Internet Protocol
 IP is a network layer protocol
 Two key functions of network layer:
 Routing: Determine route from source to destination
 Forwarding: Move packet from input to output

application
application
TCP/UDP
TCP/UDP
IP
1. Send data 2. Receive data IP
data link
data link
physical
physical

4
Packet forwarding and Routing
of Internet Protocol
IP packet Ver IHL TOS Packet length
Identification Flag Fragment Offset

TTL Protocol Header Checksum

Source IP address
payload IP header Destination IP address

Host
Router

•Where is destination
point? Router
•Data must to be forwarded
to whom next?

Router
5

Host
Characteristics of Internet
Protocol
 Unreliable/ Light overhead
 Best effort delivery
 IP doesn’t have error recovery or tracking
 Use other layer to provide reliable data transfer (TCP)
 Connectionless datagram protocol
 Each datagram handled independently

6
IP address
Classfull IP addressing
Classless Inter Domain Routing
Reserved addresses

7
IP Address (IPv4)

 IP address: 32-bit
223.1.1.1
identifier for host,
router interface 223.1.1.2
223.1.2.1

223.1.1.4 223.1.2.9
 IP addresses
associated with each 223.1.1.3 223.1.3.27
223.1.2.2

interface
 IP address is unique
223.1.3.1 223.1.3.2

223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 18
Dotted-Decimal Notation

Example:
203.178.136.63 o
259.12.49.192 x
133.27.4.27 o
8 bits
0 – 255 integer

Using four 8 bits parts to describe 32 bits address

3417476964
1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0

203 178 143 100 9


Host ID and Network ID
 IP address has two means
 Host ID
 Network ID
Network ID Host ID

1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0

203 178 143 100

 How to specify which part is host ID or net ID ?


 Classfull addressing
 Netmask and subnet 10
Classful IP addressing
8bits 8bits 8bits 8bits

Class A 0 7bit H H H
Class B 1 0 6bit N H H
Class C 1 1 0 5bit N N H
Class D 1 1 1 0 Multicast
Class E 1 1 1 1 Reserve for future use

# of network # of hosts
Class A 128 2^24
Class B 16384 65536
Class C 2^21 256 11
Disadvantage of classful IP
addressing
 Wasteful
 Classful addressing scheme (A, B, C, D, E) can
be an obstacle to fully utilized IP address space

To solve this problem …


 CIDR: Classless Inter Domain Routing
 subnet portion of address of arbitrary length
 address format: a.b.c.d/x, where x is # bits in
subnet portion of address
12
Netmask
 How can we describe two info together?
 Node ID
 Network ID
 Netmask divides IP address into two part
 Host part
 Network part
 AND calculation
 To find the network address
 To find the range of IP addresses

13
How to describe netmask
 255.255.255.224  Check only these No.
 /27 0 248
 0xFFFFFFe0 128 252
192 254
224 255
240

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0

255 255 255 224


14
How to calculate network
address
Network part Host Part

203 . 178 . 142 . 130


IP Address 11001011 10110010 10001110 10000010

255 . 255 . 255 . 224


Netmask (/27) 11111111 11111111 11111111 11100000

(bit)
27
AND
203 . 178 . 142 . 128
11001011 10110010 10001111 10000000

Network address 203.178.142.128/27


15
Netmask and the size of network

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0

255 255 255 192


 Size of network  In case of /26
 Square of 2  Host part = 6 bits
 RFC1878  26=64
 Range of host ID
 0 - 63
 64 - 127
 128 - 191
 192 - 255
16
The way to think (1)

133 27 4 160
10000101000110110000010010100000

11111111111111111111111111000000

10000101000110110000010010000000
133 27 4 128

17
The way to think (2)

133 27 4 160
10000101000110110000010010100000

11111111111111111111111111100000

10000101000110110000010010100000
133 27 4 160

18
Network and IP address
 Three type of address also exist
 Network address
 IP address which describe network itself
 Broadcast address
 IP address which can be used to send a data to all nodes
 Host address
 Normal host ID which is assign to interface

19
IP address and netmask
 Host, network or broadcast address?

(1) 203.178.142.128 /25


(2) 203.178.142.128 /24
(3) 203.178.142.127 /25
(4) 203.178.142.127 /24
 Note: With CIDR scheme, IP address and netmask must go
together

20
Subnet
 Subnet is sub-
223.1.1.1
network of assigned
223.1.2.1
network 223.1.1.2
 ISP usually assigned 223.1.1.4 223.1.2.9
one address block
223.1.2.2
223.1.1.3 223.1.3.27
 Several subnets can
be create from one subnet
block
223.1.3.1 223.1.3.2
 How to create small
subnet
 Use longer netmask network consisting of 3 subnets
21
Example: 1 to 2 subnets

11001000 00010111 00010000 00000000


200. 23. 16. 0 /24

11001000 00010111 00010000 00000000


200. 23. 16. 0 /25
11001000 00010111 00010000 10000000
200. 23. 16. 128 /25

22
Example: 1 to 4 subnets
 Network /24 is assigned
 Need to create 4 networks
 Network with 14 computer /28
 Network with 30 computer /27
 Network with 31 computer /26
 Network with 70 computer /25

/28 /27 /26 /25

/24 23
IPv4 address space
 IP address in theory
 It is possible to use 0.0.0.0  ~  255.255.255.255
 There are some addresses that are reserved
 IP addresses reserved for special utilization (RFC1918)

10.0.0.0/8
Private address 172.16.0.0/12 ~ 172.31.0.0/12
192.168.0.0/16
Loopback address 127.0.0.0
224.0.0.0
Multicast address
~ 239.255.255.255
 Local link address: 169.254.0.0/16
24
Note on IP address
 Internet currently uses IPv4: 32 bits
 133.113.215.10 (IPv4)
 IPv6: 128bits
 2001:200:0:8803::53 (IPv6)
 Topic of IPv6 will be covered later.

25
IP datagram format

26
IP header
total datagram
length (words)
IP protocol version 32 bits
number
ver head. DS length
header length len for
(bytes) fragment
16-bit identifier flgs fragmentation/
offset reassembly
QoS support time to upper header
live layer checksum
max number 32 bit source IP address
remaining hops
32 bit destination IP address
(decremented at
each router) Options (if any) E.g. timestamp,
record route
data taken, specify
upper layer protocol (variable length, list of routers
to deliver payload to typically a TCP to visit.
or UDP segment)
27
IP header (1)
 Version (4 bits)
 IPv4
 IPv6
 Header Length : 4bits
 Total length of header in 4 bytes words
 If there is no option, this value will be 5
 So Maximum header length will be 60

28
IP header (2)
 DS (Differentiated Service : 8bits)
 Previously this field is called service type
 Precedence (3bits) and TOS field (4bits)
 Currently this field is used to provide QoS
 Diffserv

29
IP header (3)
 Total length (16 bits)
 Total length is described in bytes
 Maximum total length will be 65536
 Header length inclusive
 Identification
 Find a series of IP datagram which is fragmented
 Flag
 Fragmentation offset

30
IP header (4)
 Time to live (8 bits) -TTL
 The span of the IP packet life
 The router subtract 1 from this field
 Maximum Internet diameter is 255
 Packet is thrown away when this field reaches 0
 Protocol
 Data type of payload
 Not only the IP , ICMP, IGMP and OSPF use this value

31
IP header (4)
 Checksum
 Source IP address
 32-bit IP address of sender
 Destination IP address
 32-bit IP address of receiver

32
Fragmentation (1)
 Network links have
MTU (max. transfer fragmentation:
unit) in: one large datagram
out: 3 smaller datagrams
 Different link types,
different MTUs
 Large IP datagram is reassembly
divided
 One datagram becomes
several datagrams
 “reassembled” only at
final destination

33
Fragmentation (2)
 Identification field
 ID is used to find the fragmented IP packet
 Flags (3 bits)
 Reserved
 Don’t fragment
 IP packet will not be fragmented
 ICMP error will be sent to source host
 More fragment
 Destination IP processor can recognize

34
Fragmentation (3)
 Fragmentation offset
 The offset information of fragmented packet is stored
 In units of 8 bytes

0 1399
Offset = 0/8 = 0

0 3999 1400 2799


Offset = 1400/8 = 175

2800 3999
Offset = 2800/8 = 350

35
Checksum
 Header Checksum
 At sender side
 Checksum must be set 0
 Add up all 16 bits
 Then the sum is complemented
 At receiver side
 Add up all 16 bits
 The sum must be all 1
 If it is not all 1, the IP header corrupted

36
Options
 New function can be added by using option field
 Up to 40 Bytes
Code (8) Length (8) Data (Variable length)

copy Class Number

Copy:
0: copy only in first fragment Number:
1: copy into all fragment 00000: End of option
00001: No operation
Class: 00011: Loose source route
00: Datagram control 00100: Timestamp
01: Reserved 00111: Record route
10: Debugging and measurement 01001: Strict source route 37
11: Reserved
Internet Control Message Protocol

Overview
Packet format
Ping and Traceroute

38
ICMP Overview (1)

 IP is an unreliable, connectionless protocol


 Lack of error control and assistance mechanisms
 ICMP is used by hosts & routers to
communicate network-level information
 error reporting: unreachable host, network, port,
protocol
 echo request/reply (used by ping)

39
ICMP Overview (2)

 Network layer “above” IP:


 ICMP msgs carried in IP datagrams

 ICMP message: type, code plus first 8 bytes of


IP datagram causing error

ICMP message

IP header ICMP message

Frame header IP header ICMP message


40
Review: IP header and Protocol Field

Ver HLEN DS Total Length


Fragmentation
Protocol Field:
Identification Flags
offset 1: ICMP
TTL Protocol Header Checksum 2: IGMP
Source IP address 6: TCP
17: UDP
Destination IP address
89: OSPF
Option

See this file to check other protocol number


/etc/protocols
C:\WINDOWS\system32\drivers\etc\protocols 41
Message format
 Type field defines the type of ICMP
 Code field defines the reason
 Checksum
 Each type use the rest of the header differently
0 78 15 16 31
Type Code Checksum

Rest of the header

Data

42
ICMP message types

3 Destination Unreachable

4 Source quench
Error-reporting
ICMP Message Type

5 Redirection
messages
11 Time exceeded

12 Parameter problem

8 or 0 Echo reply or request

Query 13 or 14 Time stamp request or reply


messages 17 or 18 Address mask request or reply

9 or 10 Router advertisement or solicitation

43
ICMP and debugging tools
 ICMP works usually but quietly
 Users can use ICMP as debugging tools
 ping
 traceroute

44
Ping and ICMP
 ping
 Ping can be used to check connectivity
 Sender send ICMP echo request
 Receiver reply ICMP echo reply
 Ping sets the sequence number to Identifier
field
 Ping sets the sending time in the data field
 RTT (round-trip time) can be calculated

45
Ping: An example

C:\Documents and Settings\hongson>ping www.yahoo.co.uk

Pinging www.euro.yahoo-eu1.akadns.net [217.12.3.11] with 32 bytes of data:

Reply from 217.12.3.11: bytes=32 time=600ms TTL=237


Reply from 217.12.3.11: bytes=32 time=564ms TTL=237
Reply from 217.12.3.11: bytes=32 time=529ms TTL=237
Reply from 217.12.3.11: bytes=32 time=534ms TTL=237

Ping statistics for 217.12.3.11:


Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 529ms, Maximum = 600ms, Average = 556ms

46
Traceroute and ICMP
 Source sends packet to dest
 First has TTL =1

 Second has TTL=2, etc.

 When nth datagram arrives to nth router:


 Router discards datagram

 And sends to source an ICMP message (type 11, code 0)

 Message includes name of router& IP address

 When ICMP message arrives, source calculates time

47
Traceroute and ICMP
Stopping criterion
 Packet eventually arrives at destination host

 Destination returns ICMP “host unreachable” packet


(type 3, code 3)
 When source gets this ICMP, stops.

 Traceroute does this 3 times

3 probes 3 probes

3 probes

48
Traceroute: An example
C:\Documents and Settings\hongson>tracert www.jaist.ac.jp

Tracing route to www.jaist.ac.jp [150.65.5.208]


over a maximum of 30 hops:

1 1 ms <1 ms <1 ms 192.168.1.1


2 15 ms 14 ms 13 ms 210.245.0.42
3 13 ms 13 ms 13 ms 210.245.0.97
4 14 ms 13 ms 14 ms 210.245.1.1
5 207 ms 230 ms 94 ms pos8-2.br01.hkg04.pccwbtn.net [63.218.115.45]
6 * 403 ms 393 ms 0.so-0-1-0.XT1.SCL2.ALTER.NET [152.63.57.50]
7 338 ms 393 ms 370 ms 0.so-7-0-0.XL1.SJC1.ALTER.NET [152.63.55.106]
8 402 ms 404 ms 329 ms POS1-0.XR1.SJC1.ALTER.NET [152.63.55.113]
9 272 ms 288 ms 310 ms 193.ATM7-0.GW3.SJC1.ALTER.NET [152.63.49.29]
10 205 ms 206 ms 204 ms wide-mae-gw.customer.alter.net [157.130.206.42]
11 427 ms 403 ms 370 ms ve-13.foundry2.otemachi.wide.ad.jp [192.50.36.62]
12 395 ms 399 ms 417 ms ve-4.foundry3.nezu.wide.ad.jp [203.178.138.244]
13 355 ms 356 ms 378 ms ve-3705.cisco2.komatsu.wide.ad.jp [203.178.136.193]
14 388 ms 398 ms 414 ms c76.jaist.ac.jp [203.178.138.174]
15 438 ms 377 ms 435 ms www.jaist.ac.jp [150.65.5.208]

Trace complete.

49
Summary
 Internet protocol
 IP address and IP packet format
 ICMP
 Ping
 Traceroute

50
Next week
 Routing problem
 Objective & mechanism
 Router & routing table
 Static and dynamic routing

51

You might also like