network layer4-1 chapter 4 network layer these ppt slides are originally from the kurose and...
TRANSCRIPT
Network Layer 4-1
Chapter 4Network Layer
These ppt slides are originally from theKurose and Ross’s book. But some slides aredeleted and added for my own purpose, and some of them are modified.
Network Layer 4-2
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-3
Key Network-Layer Functions
routing: determine route taken by packets from source to dest.
Routing algorithms
Network Layer 4-4
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-5
Two packet switching technologies Virtual circuit
Path is determined before data is transferred.• Connection-oriented
All packets pass through the same path(circuit). Need signaling. X.25, Frame Relay, ATM Analogy: telephone network(circuit switching)
Datagram There is no determined path, but path is determined
per packet.• Connectionless
IP Analogy: telegram
Network Layer 4-6
Routing in IP datagram
How can routers determine the path of packets to destinations? Routers use the packet’s destination
address to forward the packet. Each router has a forwarding table that
maps destination addresses to link interfaces at which the packet will be delivered to the next-hop router on the path to the destination.
Network Layer 4-7
Routing Table Mask Destination address next-hop address flags
U(UP)- Router is operating now G(gateway)- destination is in other network H(host-specific) D(added by redirection) M(modified by redirection)
reference count: # of users to use this path use: # of packets to pass through this router interface
Network Layer 4-8
Router Operation
Receive an IP packet
1. For each entry in the routing tableApply the mask to packet destination addressIf (the result matches the value in the destination field)
If (the G flag is absent)Use packet destination address as next hop address
Send packet to fragmentation module with next hop addressReturn
2. If no match is found, send an ICMP error message
3. Return
Network Layer 4-9
193.14.5.160 193.14.5.192
R1
111.0.0.0R2
R3 R4
192.16.7.0 194.17.21.0R5
m1m3
m0
default router
193.14.5.165 193.14.5.197
111.25.19.20
111.15.17.32 111.20.18.14
182.16.7.5 194.17.21.14
192.16.7.52 194.17.21.68
111.30.31.18
194.17.21.16
Network Layer 4-10
Mask destination Next hop F ref. U I
255.0.0.0 111.0.0.0 - U 0 0 m0
255.255.255.224 193.14.5.160 - U 0 0 m2
255.255.255.224 193.14.5.192 - U 0 0 m1
……… ……….. ……… ….. … …. …
255.255.255.255 194.17.21.16 111.20.18.14 UGH 0 0 m0
255.255.255.0 192.16.7.0 111.15.17.12 UG 0 0 m0
255.255.255.0 194.17.21.0 111.20.18.14 UG 0 0 m0
0.0.0.0 0.0.0.0 111.30.31.18 UG 0 0 m0
Routing Table of R1
Network Layer 4-11
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-12
The Internet Network layer
forwardingtable
Host, router network layer functions:
Routing protocols•path selection•RIP, OSPF, BGP
IP protocol•addressing conventions•datagram format•packet handling conventions
ICMP protocol•error reporting•router “signaling”
Transport layer: TCP, UDP
Link layer
physical layer
Networklayer
Network Layer 4-13
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-14
IP datagram format
ver length
32 bits
data (variable length,typically a TCP
or UDP segment)
16-bit identifier
Internet checksum
time tolive
32 bit source IP address
IP protocol versionnumber
header length (bytes)
max numberremaining hops
(decremented at each router)
forfragmentation/reassembly
total datagramlength (bytes)
upper layer protocolto deliver payload to
head.len
type ofservice
“type” of data flgsfragment
offsetupper layer
32 bit destination IP address
Options (if any) E.g. timestamp,record routetaken, specifylist of routers to visit.
how much overhead with TCP?
20 bytes of TCP 20 bytes of IP = 40 bytes +
app layer overhead
Network Layer 4-15
Header Fields(1)
version(4 bits) The current IP is version 4.
head length (4 bits) fixed part(20 bytes) + option (in 32-bit words) Ex, fixed part = 5 (160 bits)
Type of services(TOS) or Differentiated services(DS) Defines the class of datagram for quality of service.
total length (8 bits) Header + data (unit: bytes) Data 의 Size = TOTAL LENGTH - HLEN
• Maximum size of IP Datagram is 65,535 bytes long.
Network Layer 4-16
Header Fields(2)
Identification (16 bits) It identifies the datagram from a source. Normally it is incremented by 1 every
datagram. Flags (3 bits)
Two flag bits are defined:• “more fragmentation” 비트• “don’t fragment” 비트
Fragmentation offset (13 bits)
Network Layer 4-17
MTU and Fragmentation
Maximum Transmission Unit(MTU) Each physical network has its own maximum length of data
unit(PDU) it can process.• Ex, Ethernet: 1518 bytes, ATM: 53 bytes
Thus the size of the IP datagram should not be larger than MTU of the physical network it is passing through.
Fragmentation If the datagram size is larger than MTU of the physical network, the
datagram must be fragmented.
Net 1(MTU=1000)
Net 2(MTU=400)
1000 bytes 1000 bytes
Network Layer 4-18
DATA 1 DATA 2 DATA 3
400 Octet400 Octet 400 Octet400 Octet 200 Octet200 Octet
DATA 1
DATA 2
DATA 3
Original datagram (1000 octets)
Fragment offset = 0, More Fragment Bit = 1
Fragment offset = 400/8=50, More Fragment Bit = 1
Fragment offset = 800/8=100, More Fragment Bit = 0
Fragmentation
0 399
400 799
800 999
Network Layer 4-19
Header Fields(3)
Time-to-live (8 bits) It is used to control the max. # of hops(routers)
visited by the datagram. Normally it starts with 32 or 64. Each router that
processes the datagram decrements this number by 1.
If the value reaches 0, the router discards this datagram. And the router sends the ICMP message to the source host.
Protocol (8 bits) It defines the higher layer protocol that uses the
services of the IP layer.
Network Layer 4-20
Protocol Values
1 2
6 17
89
Network Layer 4-21
Checksum It is used for the error detection for the IP header.
So the checksum covers only the header. If the checksum is incorrect, the receiver discards
this datagram. Sender
packet is divided into k sections, each of n bits(16 bits) all sections are added together using 1’s complement the final result is complemented to make the checksum
Receiver packet is divided into k sections, each of n bits all sections are added together using 1’s complement the result is complemented If the final result is 0, then no error
Network Layer 4-22
n bits
n bits
all 0s
n bits
n bits
n bits
Section 1
Section 2
checksum
Section n
Sum
checksum
….….
complement
sender
n bits
n bits
n bits
n bits
n bits
All 0s?
Section 1
Section 2
checksum
Section n
Sum
checksum
….….
complement
receiver
n bits
checksum
packet
Network Layer 4-23
Example
Network Layer 4-24
Option
Options(variable) It is used for testing and debugging. The following fields are defined.
• Record route• loose source routing• strict source routing• timestamp
Network Layer 4-25
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-26
Addressing
Internet architecture Classful addressing Subnetting Private addresses and NAT Classless addressing
Network Layer 4-27
Internet Architecture
The internet consists of many heterogeneous networks. A network of networks
The Internet is a special internet which connects all networks based on the TCP/IP protocol.
In Internet, internetworking devices called routers(or gateways) provide interconnections among all networks.
Network Layer 4-28
Net 1 Net 2 Net 3R1 R2
Internet
real structure
router physicalnet
host
Internet as a universal network
host
user’s view
Virtual, uniform one network
Network Layer 4-29
IP address
IP addresses denote the connection(interface) to the Internet. cf> telephone address, ethernet address
IP addresses are unique. Each address defines only on connection to
the Internet. IP addresses are global(universal).
Any host connected to the Internet must use the same IP addressing scheme.
Network Layer 4-30
IP address
An IP address is a 32 bits long. It consists of two parts: net-id and host-
id.
Net id Host id
32 bits
Denote a specificphysical networkIn the Internet
Denote a connection in a specificphysical network
Network Layer 4-31
Dotted decimal notation
Network Layer 4-32
Types of IP addresses
Network Layer 4-33
Range of Each Class
Network Layer 4-34
Net-id and host-id of each class
Network Layer 4-35
Network Address
Network Layer 4-36
Sample Network
Network Layer 4-37
Special IP addresses
0’s mean “this”, 1’s mean “all”
Limited broadcast( local net)2
all 0s
all 0s
all 1s
all 1snet
host
127 anything (often 1)
This host1
Host on this net1
Directed broadcast for net2
Loopback3
Notes:1 Allowed only at system startup(bootstrap) and is never a valid destination address.2 Never a valid source address.3 Should never appear on a network. Used in testing.
Network Layer 4-38
Subnetting
IP address is designed with two levels of hierarchy: netid and hostid.
Sometimes the block of a network address assigned to an organization need to be divided for efficient routing, so that an organization has several subnetworks(subnets).
Subnetting provides a mean to have three levels of hierarchy.
Network Layer 4-39
H1
128.10.1.1
H2
128.10.1.2
Network 128.10.1.0
H3
128.10.2.1
H4
128.10.2.2
Network 128.10.2.0
REST OF THEINTERNET
all traffic to128.10.X.X
R
All packets with 128.10.x.x arecoming to this organization from outside.
Network Layer 4-40
Address with subnet-id
Network Layer 4-41
Subnet Mask
The subnet mask specifies how many bits in the host-id are assigned for subnet-id.
Network Layer 4-42
Subnet Example
Network ID Subnet ID Host ID
16 8 8
11111111 11111111 11111111 00000000
Network ID Subnet ID Host ID
16 10 6
11111111 11111111 11111111 11 000000
0xffffff00 = 255.255.255.0
0xffffffc0 = 255.255.255.192
Network Layer 4-43
Private Address
The private addresses are not recognized in the global Internet.
IP private addresses can only be used in local networks.
The blocks of IP private addresses 10.0.0.0 ~ 10.255.255.255 172.16.0.0 ~ 172.31.255.255 192.168.0.0 ~ 192.168.255.255
The local sites with private addresses can be connected to the global Internet through NAT.
Network Layer 4-44
NAT: Network Address Translation
Motivation: local network uses just one IP address as far as outside word is concerned: no need to be allocated range of addresses from
ISP: - just one IP address is used for all devices can change addresses of devices in local network
without notifying outside world can change ISP without changing addresses of
devices in local network devices inside local net not explicitly
addressable, visible by outside world (a security plus).
Network Layer 4-45
Network Address Translation(NAT)
Network Layer 4-46
Network Layer 4-47
Translation Table
How does a NAT router know the destination address for a packet coming from the outside? For many-to-many relation between the private address
network and global Internet servers, we need the following translation table.
Private Address
Private Port
ExternalAddress
External Port
TransportProtocol
172.18.3.1 1400 25.8.3.2 80 TCP
172.18.3.2 1401 25.8.3.2 80 TCP
... ... ... ... ...
Network Layer 4-48
Classless Interdomain Routing(CIDR)
Classful address IP addresses have three classes depending on the
leftmost bit(s). So the length of the net-id has fixed depending on
the classes. Classless address
IP addresses has no classes. The length of net-id is variable.
The length of net-id is specified for each IP address. CIDR uses classless address.
Network Layer 4-49
IP addressing: CIDR
CIDR: Classless InterDomain Routing subnet portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in
subnet portion of address
11001000 00010111 00010000 00000000
subnetpart
hostpart
200.23.16.0/23
Network Layer 4-50
CIDR notation
In CIDR, an IP address is expressed as: Network address/length
Ex) 234.170.168.0/21–(234.170.168.0, 234.170.175.255) block Dotted decimal 32-bit binary equivalentlowest 234.170.168.0 11101010 10101010 10101000 00000000highest 234.170.175.255 11101010 10101010 10101111 11111111CIDR mask 11111111 11111111 11111000 00000000
Network Layer 4-51
Ex) 198.32.0.0/16 (198.32.0.0, 198.32.255.255) block
lowest 198.32.0.0 11000110 00100000 00000000 00000000Highest 198.32.255.255 11000110 00100000 11111111 11111111
Network Layer 4-52
An ISP has the address block of 206.0.64.0/18 (64/24s).If a customer requests 800 IP addresses, then the ISP can assign the address block of 206.0.68.0/22 (4 contiguous/24s) to the customer.
What is the advantage of using CIDR comparing with the case of assigningone class B address or 4 class C addresses?
ISP’s block 11001110.00000000.01000000.00000000 206.0.64.0/18
client’s block 11001110.00000000.01000100.00000000 206.0.68.0/22
Class C(0) 11001110.00000000.01000100.00000000 206.0.68.0/24Class C(1) 11001110.00000000.01000101.00000000 206.0.69.0/24Class C(2) 11001110.00000000.01000110.00000000 206.0.70.0/24Class C(3) 11001110.00000000.01000111.00000000 206.0.71.0/24
Example Example
Network Layer 4-53
IP addresses: how to get one?
Q: How does host get IP address?
hard-coded by system admin in a file Wintel: control-panel->network->configuration->tcp/ip-
>properties UNIX: /etc/rc.config
DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server “plug-and-play”
(more in next chapter)
Network Layer 4-54
IP addresses: how to get one?
Q: How does network get subnet part of IP addr?
A: gets allocated portion of its provider ISP’s address space
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 ... ….. …. ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
Network Layer 4-55
IP addressing: the last word...
Q: How does an ISP get block of addresses?
A: ICANN: Internet Corporation for Assigned
Names and Numbers allocates addresses manages DNS assigns domain names, resolves disputes
Network Layer 4-56
Chapter 4: Network Layer
4. 1 Introduction 4.2 Virtual circuit
and datagram networks
4.3 What’s inside a router
4.4 IP: Internet Protocol Datagram format IPv4 addressing ICMP IPv6
4.5 Routing algorithms Link state Distance Vector Hierarchical routing
4.6 Routing in the Internet RIP OSPF BGP
4.7 Broadcast and multicast routing
Network Layer 4-57
ICMP: Internet Control Message Protocol
used by hosts & routers to communicate network-level information error reporting:
unreachable host, network, port, protocol
echo request/reply (used by ping)
network-layer “above” IP: ICMP msgs carried in IP
datagrams ICMP message: type, code
plus first 8 bytes of IP datagram causing error
Type Code description0 0 echo reply (ping)3 0 dest. network unreachable3 1 dest host unreachable3 2 dest protocol unreachable3 3 dest port unreachable3 6 dest network unknown3 7 dest host unknown4 0 source quench (congestion control - not used)8 0 echo request (ping)9 0 route advertisement10 0 router discovery11 0 TTL expired12 0 bad IP header
Network Layer 4-58
Error Reporting messages(1)
Network Layer 4-59
Error Reporting messages(2)
Destination Unreachable When a router or host can’t route a
datagram, it discards the datagram and sends a destination unreachable message to the source.
Source quench When a router or host discards datagrams
due to congestion, It sends a source quench message to the source.
Network Layer 4-60
Error Reporting messages(3)
Time exceeded When TTL value is 0, a router discards the datagram
and send a Time exceeded message the original source host.
When all fragmented datagrams of one datagram do not arrive at the destination within a certain time limit, this message is generated.
Parameter problem When any ambiguous or missing values in the
header of the datagram are detected,
Network Layer 4-61
Error Reporting messages(4)
Redirection The host may send a datagram which is
destined for a wrong router because of its old routing table. In this case the router will forward this datagram to the correct router and at the same time it sends a redirection message back to the host.
Network Layer 4-62
Query Messages(1)
Network Layer 4-63
Query Messages(2)
Error Request and Reply Used for diagnostic purpose
Time stamp Request and Reply When routers or hosts determine the round-
trip time needed for a datagram to travel between them
Address Mask Request and Reply When a host want to know the subnet mask
of the network it belongs to
Network Layer 4-64
Query Messages(3)
Router Solicitation and Advertisement When a host want to know a default router,
it broadcasts a router solicitation message. A router can send a router advertisement
message periodically even if no host has solicited.
Network Layer 4-65
ICMP message encapsulation
Network Layer 4-66
Example of ICMP Use
Ping Traceroute MTU discovery
Network Layer 4-67
Traceroute and ICMP
Source sends series of UDP segments to dest First has TTL =1 Second has TTL=2, etc. Unlikely port number
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 RTT
Traceroute does this 3 times
Stopping criterion UDP segment eventually
arrives at destination host
Destination returns ICMP “host unreachable” packet (type 3, code 3)
When source gets this ICMP, stops.