CN CH 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

Computer Networking

Chapter #4

Dr. Abdulrhaman Alameer


Computer Network

Application HTTP ,FTP , E-mail

Transport UDP, TCP 2 handshake, 3 handshake Reliability

Network Routing and Forwarding

Data link
Physical

2
Network Layer

3
Network Layer
• Network Layer
• It is responsible for transporting packet from sending to receiving host
- On sending side encapsulates packet into datagrams
- On receiving side, delivers packet to transport layer

application Data
Data application
transport Data :TCP / UDP
Data :TCP / UDP transport
network Datagrams
network
Datagrams
data link data link
physical physical

4
Network Layer
• Two functions in the network-layer
• Forwarding: move packets from router’s input to appropriate router
output.

• Routing: determine route taken by packets (planning trip) from


source to destination. (routing algorithms).

Routing Algorithm
Routing Algorithm
Forwarding table
Header value Output link Forwarding table
§
application 100
101
3
2
Header value Output link
application
100 3
102 2
transport 101
102
2
2 transport
network Datagrams
network
Datagrams
data link data link
physical physical

5
Network Layer
• Connection, Connection-less Service

• Connection Service
virtual-circuit

• Connectionless Service
datagram

6
Network Layer
• Connection Service
virtual-circuit (VC) : It is used to transport data over a packet switch computer network, in
which it needs to setup a call to appear as if there is a physical path established between
the final destination and source and through which all packets can be routed during the call.
- Each packet carries VC identifier (not destination host address) for forwarding.
- Every router on source-dest path maintains “state” for each passing connection
- Used in ATM
- Not used in today’s Internet

application application
5. data flow begins 6. receive data
transport transport
network 4. call connected 3. accept call
1. initiate call network
data link 2. incoming call
data link
physical physical

7
Network Layer
• Connection, connection-less service

• Connection Service
virtual-circuit (VC)

• Connectionless Service
datagram

8
Network Layer
• Connection-less Service
Datagram: It is used to transport data over a packet switch computer network.
- Each packet uses destination host address for forwarding using destination host address
- No need to setup a call at network layer
- Every router: no state maintains about end-to-end connections

Each packet call as Datagrams


application 1 2 3 4 5 6 application
transport transport
network 1. send datagrams 2. receive datagrams network
data link 3 data link
5 6 1
physical physical
4

Datagram 2

9
Network Layer
• Datagram or VC network: why?
Internet (datagram) ATM (VC)
• data exchange among • evolved from telephony
computers • human conversation:
– “elastic” service, no strict – strict timing, reliability
timing req.
requirements
– need for guaranteed
• many link types service
– different characteristics • “dumb” end systems
– uniform service difficult – telephones
• “smart” end systems – complexity inside network
(computers)
– can adapt, perform control,
error recovery
– simple inside network,
complexity at “edge”
10
Network Layer
The Internet network layer
• host, router network layer functions:

transport layer: TCP, UDP

routing protocols IP protocol


• path selection • addressing conventions
• RIP, OSPF, BGP • datagram format
network • packet handling conventions
layer forwarding
table
ICMP protocol
• error reporting
• router
“signaling”
link
linklayer
layer

physical
physicallayer
layer
- (RIP): Routing Information Protocol
- (OSPF): Open Shortest Path First
- (BGP): Border Gateway Protocol
11
IP datagram format
IP protocol version 32 bits
number total datagram
header length length (bytes)
ver head. type of length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much overhead? data taken, specify
(variable length, list of routers
❖ 20 bytes of TCP
typically a TCP to visit.
❖ 20 bytes of IP
or UDP segment)
❖ = 40 bytes + app
layer overhead

12
IP addressing: introduction
223.1.1.1

• IP address: 32-bit 223.1.2.1


identifier for host, router
interface 223.1.1.2
223.1.1.4 223.1.2.9

• interface: connection
between host/router and 223.1.1.3
223.1.3.27

physical link 223.1.2.2

– routers typically have


multiple interfaces
– host typically has one active 223.1.3.1 223.1.3.2

interface (e.g., wired


Ethernet, wireless 802.11)
• one IP address associated 223.1.1.1 = 11011111 00000001 00000001 00000001
with each interface 223 1 1 1

13
IP addressing: introduction

14
Subnets
• IP address: 223.1.1.1
–subnet part - high order
bits 223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
–host part - low order
bits 223.1.2.2
223.1.1.3 223.1.3.27
• what’s a subnet ?
subnet
–device interfaces with
same subnet part of IP 223.1.3.1 223.1.3.2
address
–can physically reach
each other without network consisting of 3 subnets
intervening router

15
What is ICANN
• Internet Corporation for Assigned Names and Numbers
(ICANN): It is a corporation responsible for:

▪ Allocates addresses
▪ Assigns domain names, resolves disputes
▪ Manages DNS

• Example:

• Educational institutions Jazan Universities 223.1.1.0/24

• Companies 223.1.2.0/24

• Internet service providers. STC 223.1.4.0/24

16
ICANN

Host
223.1.1.1

223.1.2.0/24 223.1.2.9
223.1.1.0/24
Companies
Jazan Universities

223.1.4.0/24
STC

17
IP addressing: introduction
223.1.1.3 223.1.2.1

223.1.1.6 223.1.2.8

Jazan Universities Companies


223.1.1.0/24 223.1.2.0/24

223.1.1.2 223.1.1.1
223.1.2.4

18
ICANN

Host
223.1.1.1

223.1.2.0/24 223.1.2.9
223.1.1.0/24
Companies
Jazan Universities

223.1.4.0/24 How does a host get IP address?


STC

19
How does a host get IP address?
• DHCP: Dynamic Host Configuration Protocol: dynamically get address from
as server.
• Host broadcasts “DHCP discover” msg [optional] DHCP Server Host

• DHCP server responds with “DHCP offer” msg [optional].


• Host requests IP address: “DHCP request” msg Port 67 Port 68
• DHCP server sends address: “DHCP ack” msg

20
How does a host get IP address?
DHCP server: 223.1.2.5 DHCP discover Client Port 68
Port 67 src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654

DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
DHCP client-server scenario yiaddrr: 223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs

DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
Network Layer
21
DHCP

DHCP
server

Host
223.1.1.1

arriving DHCP
223.1.2.0/24 223.1.2.9
223.1.1.0/24 client needs
223.1.1.2 address in this
Companies network

Jazan Universities

223.1.4.0/24 How does a host get IP address?


STC

22
DHCP
DHCP DHCP ❖ connecting laptop needs its
DHCP UDP IP address, addr of first-hop
DHCP IP router, addr of DNS server:
DHCP Eth
Phy
use DHCP
DHCP request encapsulated
DHCP

in UDP, encapsulated in IP,
DHCP DHCP 168.1.1.1 encapsulated in 802.3
DHCP UDP Ethernet
IP
Ethernet frame broadcast
DHCP

DHCP Eth router with DHCP
Phy server built into (dest: FFFFFFFFFFFF) on LAN,
router received at router running
DHCP server
❖ Ethernet demuxed to IP
demuxed, UDP demuxed to
DHCP
Network Layer 4-23
23
DHCP
DHCP DHCP
• DHCP server formulates
DHCP UDP
DHCP ACK containing
DHCP IP
client’s IP address, IP
DHCP Eth
address of first-hop router
Phy
for client, name & IP
address of DNS server

❖ encapsulation of DHCP
DHCP DHCP server, frame forwarded
DHCP UDP to client, demuxing up to
DHCP IP DHCP at client
DHCP Eth router with DHCP
DHCP
Phy server built into ❖ client now knows its IP
router address, name and IP
address of DSN server, IP
address of its first-hop
router

Network Layer 4-24


24
DHCP
• DHCP: Dynamic Host Configuration Protocol: dynamically get address from
as server.
to dynamically obtain its IP address from
• DHCP allows host
network server when it joins network.
▪ Can renew its lease on address in use
▪ Allows reuse of addresses (only hold address while connected/“on”)
▪ Support for mobile users who want to join network (more shortly)

25
NAT: network address translation
rest of local network
Internet (e.g., home network)
10.0.0/24 10.0.0.1

10.0.0.4
Jazan U 10.0.0.2
138.76.29.7

10.0.0.3

• Local network uses just one IP address as far as outside world is concerned
• Range of addresses not needed from Internet service provider (ISP): just one IP
address 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).
26
NAT: network address translation
NAT translation table 1: host 10.0.0.1
sends datagram to
2: NAT router WAN side addr LAN side addr 128.119.40.186, 80
changes datagram
source addr from 138.76.29.7, 5001 10.0.0.1, 3345
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table S: 10.0.0.1, 3345
D: 128.119.40.186, 80 10.0.0.1

S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4 1
10.0.0.2
S: 128.119.40.186, 80 138.76.29.7
D: 138.76.29.7, 5001 3 S: 128.119.40.186, 80
3: reply arrives D: 10.0.0.1, 3345 4
dest. address:
138.76.29.7, 5001 4: NAT router
changes datagram 10.0.0.3
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345

implementation: NAT router must:


• Outgoing datagrams: replace (source IP address, port #) of every outgoing datagram to (NAT IP address,
new port #), remote clients/servers will respond using (NAT IP address, new port #) as destination addr.
• Remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #)
translation pair
• Incoming datagrams: replace (NAT IP address, new port #) in dest fields of every incoming datagram with
corresponding (source IP address, port #) stored in NAT table.
27
Network Layers
Network Layers
Data: FTP, Email, STMP, IMTP, HTTP

Data TCP UDP

TCP IP add.
Data
UDP

Data Link

Physical

28
ICMP: internet control message protocol
• Notes
• IP protocol is a best-effort delivery service that delivers a datagram from its source to final
destination.
• What happens if a router must discard a datagram because it cannot find a router to the
final destination, or because the time-to-live field has a zero value?

ICMP
• ICMP Message Data
TCP
UDP
IP add.

• ICMP carried in IP datagrams


• Used by hosts & routers to communicate network-
level information ICMP Messg.

– error reporting: unreachable host, network, port,


protocol. Query rept. Error Messg.
– echo request/reply (used by ping)
Helping a host or a network manager get specific
information from a router or another host

29
ICMP: internet control message protocol
• ICMP message: type, code plus first 8 bytes of IP datagram
causing error
Type Code Description
0 0 echo reply (ping)
3 0 dest. network unreachable
3 1 dest host unreachable
3 2 dest protocol unreachable
3 3 dest port unreachable
3 6 dest network unknown
3 7 dest host unknown
4 0 source quench (congestion control - not used)

8 0 echo request (ping)


9 0 route advertisement
10 0 router discovery
11 0 TTL expired
12 0 bad IP header

30
Network Layers
Network Layers
Data: FTP, Email, STMP, IMTP, HTTP

Data TCP UDP

TCP ICMP
Data IP add.
UDP IPv4 IPv6

Data Link

Physical

31
IPv6
• It is the next generation version of the Internet Protocol (IP), the communications
protocol that provides an identification and location system for computers on
networks and routes traffic across the Internet.

• IPv6 utilizes 128 bit address.


• Motivation:
- Header format helps speed processing forwarding.
- Header changes to facilitate QoS
- No fragmentation allowed.

32
IPv6 Changes From IPv4
32 bits 32 bits

ver pri flow label ver head. type of length


len service
payload len next hdr hop limit fragment
source address 16-bit identifier flgs
offset
(128 bits) time to upper header
destination address live layer checksum
(128 bits) 32 bit source IP address
32 bit destination IP address
data
options (if any)

• Checksum: removed entirely to reduce processing time at each hop


data
• Options: allowed, but outside of header, indicated by “Next Header” (variable length,
field.
typically a TCP
• ICMPv6: new version of ICMP or UDP segment)
- Additional message types, e.g. “Packet Too Big”

33
IPv6 Changes From IPv4

34
Transition from IPv4 to IPv6
• Not all routers can be upgraded simultaneously.
• How will network operate with mixed IPv4 and IPv6
routers?
• Tunneling: IPv6 datagram carried as payload in IPv4
datagram among IPv4 routers.

IPv4 header fields IPv6 header fields


IPv4 payload
IPv4 source, dest addr IPv6 source dest addr
UDP/TCP payload

IPv6 datagram
IPv4 datagram

35
Interplay between routing, forwarding
routing algorithm determines
routing algorithm
end-end-path through network
forwarding table determines
local forwarding table
local forwarding at this router
dest address output link
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1

IP destination address in
arriving packet’s header
1
3 2

36
Graph abstraction
5

v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
graph: G = (N,E)

N = set of routers = { u, v, w, x, y, z }

E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }

aside: graph abstraction is useful in other network contexts, e.g.,


P2P, where N is set of peers and E is set of TCP connections

37
Graph abstraction: costs
5
c(x,x’) = cost of link (x,x’)
3 e.g., c(w,z) = 5
v w 5
2
u cost could always be 1, or
2
3
1 z inversely related to bandwidth,
1 2 or inversely related to
x 1
y
congestion

cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

key question: what is the least-cost path between u and z ?


routing algorithm: algorithm that finds that least cost path

38
Routing algorithm classification
Q: global or decentralized Q: static or dynamic?
information?
global: static:
• all routers have complete ❖ routes change slowly over
topology, link cost info
time
• “link state” algorithms
decentralized: dynamic:
• router knows physically- ❖ routes change more
connected neighbors, link costs quickly
to neighbors
• iterative process of ▪ periodic update
computation, exchange of info ▪ in response to link cost
with neighbors
• “distance vector” algorithms changes

39
A Link-State Routing Algorithm
Dijkstra’s algorithm
notation:
• net topology, link costs
known to all nodes • c(x,y): link cost from
node x to y; = ∞ if not
– accomplished via “link direct neighbors
state broadcast”
– all nodes have same info
• D(v): current value of
cost of path from source
• computes least cost paths to dest. v
from one node (‘source”) • p(v): predecessor node
to all other nodes along path from source to
– gives forwarding table for v
that node • N': set of nodes whose
• iterative: after k least cost path definitively
iterations, know least cost known
path to k destinations

40
Dijkstra’s algorithm: example
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
u 7,u 3,u 5,u ∞ ∞ e.g., D(v) = min( D(v), D( w) + c( w, v))
0
1 uw 6,w 5,u 11,w ∞ = min{7,3 + 3} = 6
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x x
9
4 uwxvy 12,y
5 uwxvyz 5 7
4
8
3
This example is to find the u w y z
2
forwarding table of router U
3
or the shortest paths from 7 4
router U to every v
routers(X,W,V,Y,Z)
41
Dijkstra’s algorithm: example
❖ The result will be the forwarding table for
router U:
❖ Any packet arrives to U, it will be
forwarded based on this forwarding table.
x
9

5 7
4
8 destination link
3 w z v (u,w)
u y
2 x (u,x)
3 y (u,w)
7 4
w (u,w)
v z (u,w)

42
4-43
2 1
1 3
5 6
2
3 4
1 2
3
2
5
4

Iteration N D2 D3 D4 D5 D6
Initial
Distance vector algorithm
Bellman-Ford equation (dynamic programming)

let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min {c(x,v) + dv(y) }

cost from neighbor v to destination y


cost to neighbor v

min taken over all neighbors v of x

45
Distance vector algorithm

key idea:
❖from time-to-time, each node sends its own
distance vector estimate to neighbors
❖when x receives new DV estimate from neighbor,
it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N

❖ under minor, natural conditions, the estimate Dx(y)


converge to the actual least cost dx(y)

46
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to
table x y z x y z
x 0 2 7 x 0 2 3

from
from

y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0

node y cost to
table x y z y
2 1
x ∞ ∞ ∞
x z
from

y 2 0 1 7
z ∞∞ ∞

node z cost to
table x y z
x ∞∞ ∞
from

y ∞∞ ∞
z 7 1 0
time
Network Layer 4-47
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3

from
from

y ∞∞ ∞ y 2 0 1

from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from

from

y 2 0 1 y 2 0 1 7

from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0

node z cost to cost to cost to


table x y z x y z x y z

x ∞∞ ∞ x 0 2 7 x 0 2 3
from

from

y 2 0 1 y 2 0 1
from

y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Network Layer 4-48
Distance vector algorithm

4-49
Distance vector algorithm

4-50
Distance vector algorithm

4-51
Distance vector algorithm

4-52
Comparison of LS and DV algorithms
message complexity robustness: what happens if
• LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent LS:
• DV: exchange between neighbors – node can advertise incorrect
only link cost
– convergence time varies – each node computes only its
own table
speed of convergence
DV:
• LS: O(n2) algorithm requires
O(nE) msgs – DV node can advertise
incorrect path cost
– may have oscillations
– each node’s table used by
• DV: convergence time varies others
– may be routing loops • error propagate thru
– count-to-infinity problem network

53
Hierarchical routing
• collect routers into • routers in same AS run
regions, “autonomous same routing protocol
– “intra-AS” routing
systems” (AS) protocol
• Each AS within an ISP – routers in different AS can
run different intra-AS
– ISP may consist of one routing protocol
or more ASes
gateway router:
• at “edge” of its own AS
• has link to router in another
AS

54
Interconnected ASes

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
❖ forwarding table
configured by both intra-
Intra-AS Inter-AS
and inter-AS routing
Routing
algorithm
Routing
algorithm
algorithm.

Forwarding
table

55
Interconnected ASes

56
Intra-AS Routing

❖ Also known as interior gateway protocols (IGP)


❖ Most common intra-AS routing protocols:
▪ RIP: Routing Information Protocol
▪ OSPF: Open Shortest Path First
▪ IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)

57
Intra-AS Routing
• RIP ( Routing Information Protocol)
• Uses distance vector algorithm
• distance-vector routing protocols which employ the hop count
as a routing metric

from router A to destination subnets:

subnet hops
u v
u 1
A B w v 2
w 2
x 3
x
z C D y 3
y z 2

58
Intra-AS Routing
• OSPF (Open Shortest Path First)
• uses link state algorithm
– route computation using Dijkstra’s algorithm

59
Inter-AS tasks
❖ suppose router in AS1
receives datagram
destined outside of AS1:
▪ router should forward
packet to gateway
router

3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d

60
Inter-AS tasks
• Internet inter-AS routing: BGP
• BGP (Border Gateway Protocol):
• “Glue that holds the Internet together”.
• The Border Gateway Protocol (BGP) is the
protocol backing the core routing decisions on
the Internet.
• Allows subnet to advertise its existence to rest
of Internet: “I am here”

61
Broadcast routing
❖deliver packets from source to all other nodes
❖source duplication is inefficient:
duplicate
duplicate R1 creation/transmission R1
duplicate
R2 R2

R3 R4 R3 R4

source in-network
duplication duplication

❖ source duplication: how does source determine


recipient addresses?

62
Broadcast routing
• In-network duplication
• flooding: when node receives broadcast packet,
sends copy to all neighbors
– problems: cycles & broadcast storm
• spanning tree:
– no redundant packets received by any node

63
Spanning tree

Spanning Tree Protocol (STP) is a network protocol


that builds a logical loop-free topology for
Ethernet networks.

A A

B B
c c

D D
F E F E

G G
(a) Broadcast initiated at A (b) Broadcast initiated at D

64
Shortest path tree
• mcast forwarding tree: tree of shortest path routes
from source to all receivers
– Dijkstra’s algorithm

s: source LEGEND
R1 2 router with attached
1 R4
group member
R2 5 router with no attached
3 4 group member
R5
i link used for forwarding,
R3 6
i indicates order link
R6 R7 added by algorithm

65
Chapter 4: done!
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and – link state, distance vector,
datagram networks hierarchical routing

4.3 what’s inside a router 4.6 routing in the Internet


– RIP, OSPF, BGP
4.4 IP: Internet Protocol
– datagram format, IPv4
4.7 broadcast and multicast
addressing, ICMP, IPv6 routing
❖ understand principles behind network layer services:
▪ network layer service models, forwarding versus routing
how a router works, routing (path selection), broadcast,
multicast
❖ instantiation, implementation in the Internet

66

You might also like