You are on page 1of 20

Computer and

Communication Networks
EE-357
By Dr Mir Yasir Umair
Associate Professor, MCS, NUST
Network Layer
Introduction
Chapter 4: network layer
chapter goals:
❖ 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

Network Layer 4-3


Chapter 4: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and datagram o link state
networks o distance vector
o hierarchical routing
4.3 what’s inside a router
4.6 routing in the Internet
4.4 IP: Internet Protocol
o RIP
o datagram format
o OSPF
o IPv4 addressing
o BGP
o ICMP
o IPv6
4.7 broadcast and multicast
routing

Network Layer 4-4


Network layer
application

• transport segment from transport


network

sending to receiving host data link


physical
network network
• on sending side network
data link
physical
data link
physical

encapsulates segments
data link
physical network network

into datagrams data link data link


physical physical

• on receiving side, delivers network network

segments to transport data link


physical
network
data link
physical

layer data link


physical

• network layer protocols in network


application
transport

every host, router


data link network network
network physical data link data link
data link physical physical
• router examines header physical

fields in all IP datagrams


passing through it

Network Layer 4-5


Two key network-layer functions
• forwarding: move packets analogy:
from router’s input to
appropriate router output ❖ routing: process of
planning trip from source
• routing: determine route to dest
taken by packets from source
to dest. ❖ forwarding: process of
getting through single
o routing algorithms
interchange

Network Layer 4-6


Interplay between routing and forwarding

routing algorithm routing algorithm determines


end-end-path through network

local forwarding table forwarding table determines


header value output link local forwarding at this router
0100 3
0101 2
0111 2
1001 1

value in arriving
packet’s header
0111 1

3 2

Network Layer 4-7


Connection setup
• network vs transport layer connection service:
o network: between two hosts (may also involve
intervening routers in case of VCs)
o transport: between two processes

Network Layer 4-8


Chapter 4: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and datagram o link state
networks o distance vector
o hierarchical routing
4.3 what’s inside a router
4.6 routing in the Internet
4.4 IP: Internet Protocol
o RIP
o datagram format
o OSPF
o IPv4 addressing
o BGP
o ICMP
o IPv6
4.7 broadcast and multicast
routing

Network Layer 4-9


Connection, connection-less service
❖ datagram network provides network-layer connectionless service
❖ virtual-circuit network provides network-layer connection service
❖ analogous to TCP/UDP connecton-oriented / connectionless transport-layer services,
but:
▪ service: host-to-host
▪ no choice: network provides one or the other
▪ implementation: in network core

Network Layer 4-10


Virtual circuits
“source-to-dest path behaves much like
telephone circuit”
o performance-wise
o network actions along source-to-dest path

• call setup, teardown for each call before data can flow
• each packet carries VC identifier (not destination host address)
• every router on source-dest path maintains “state” for each passing
connection
• link, router resources (bandwidth, buffers) may be allocated to VC
(dedicated resources = predictable service)

Network Layer 4-11


VC implementation
a VC consists of:
1. path from source to destination
2. VC numbers, one number for each link along path
3. entries in forwarding tables in routers along path
❖ packet belonging to VC carries VC number (rather than dest address)
❖ VC number can be changed on each link.
▪ new VC number comes from forwarding table

Network Layer 4-12


VC forwarding table
12 22 32

1 3
2
VC number
interface
forwarding table in number
northwest router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #

1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …

VC routers maintain connection state information!


Network Layer 4-13
Virtual circuits: signaling protocols
• used to setup, maintain teardown VC
• 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

Network Layer 4-14


Datagram networks
• no call setup at network layer
• routers: no state about end-to-end connections
o no network-level concept of “connection”

• packets forwarded using destination host address

application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical

Network Layer 4-15


Datagram forwarding table
4 billion IP addresses, so
routing algorithm rather than list individual
destination address
local forwarding table
list range of addresses
dest address output link (aggregate table entries)
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

Network Layer 4-16


Datagram forwarding table
Destination Address Range Link Interface

11001000 00010111 00010000 00000000


through 0
11001000 00010111 00010111 11111111

11001000 00010111 00011000 00000000


through 1
11001000 00010111 00011000 11111111

11001000 00010111 00011001 00000000


through 2
11001000 00010111 00011111 11111111

otherwise 3

Network Layer 4-17


Longest prefix matching
longest prefix matching
when looking for forwarding table entry for given
destination address, use longest address prefix that
matches destination address.

Destination Address Range Link interface

11001000 00010111 00010*** ********* 0

11001000 00010111 00011000 ********* 1

11001000 00010111 00011*** ********* 2

otherwise 3

examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 which interface?
Network Layer 4-18
Datagram or VC network: why?
Internet (datagram) ATM (VC)
• data exchange among • evolved from
computers telephony
o “elastic” service, no • human conversation:
strict timing req. o strict timing, reliability
• many link types requirements
o need for guaranteed
o different characteristics service
o uniform service difficult • “dumb” end
• “smart” end systems systems
(computers) o telephones
o can adapt, perform o complexity inside
control, error recovery network
o simple inside network,
complexity at “edge”

Network Layer 4-19


Thank you

You might also like