Module 3 Part 1
Module 3 Part 1
Layer
Module 3 – PART 1
Network Layer
• Network layer provides host-to-host communication service.
• Unlike the transport and application layers, there is a piece of the
network layer in each and every host and router in the network.
• Two important functions of the network layer are forwarding and
routing.
• Forwarding involves the transfer of a packet from an incoming link to
an outgoing link within a single router.
• Routing involves all of a network’s routers, whose collective
interactions via routing protocols determine the paths that packets
take on their trips from source to destination node.
• Figure shows a simple network with two hosts, H1 and H2, and several
routers on the path between H1 and H2.
• Suppose that H1 is sending information to H2.
• The network layer in H1 takes segments from the transport layer in H1,
encapsulates each segment into a datagram (that is, a network-layer
packet), and then sends the datagrams to its nearby router, R1.
• At the receiving host, H2, the network layer receives the datagrams from
its nearby router R2, extracts the transport-layer segments, and delivers
the segments up to the transport layer at H2.
• The primary role of the routers is to forward datagrams from input links
to output links.
• The routers are shown with a truncated protocol stack, that is, with no
upper layers above the network layer, because (except for control
purposes) routers do not run application- and transport-layer protocols.
Forwarding and Routing
• The role of the network layer is to move packets from a sending host
to a receiving host.
• To do so, two important network-layer functions can be identified:
• Forwarding: When a packet arrives at a router’s input link, the router
must move the packet to the appropriate output link. For example, a
packet arriving from Host H1 to Router R1 must be forwarded to the
next router on a path to H2.
• Routing : The network layer must determine the route or path taken
by packets as they flow from a sender to a receiver.
• The algorithms that calculate these paths are referred to as routing
algorithms. A routing algorithm would determine, for example, the
path along which packets flow from H1 to H2.
• Every router has a forwarding table.
• A router forwards a packet by examining the value of a field in
the arriving packet’s header, and then using this header value to
index into the router’s forwarding table.
• The value stored in the forwarding table entry for that header
indicates the router’s outgoing link interface to which that packet is to
be forwarded.
• Depending on the network-layer protocol, the header value could be
the destination address of the packet or an indication of the
connection to which the packet belongs.
• A packet with a header field value of 0111 arrives to a router.
• The router indexes into its forwarding table and determines that the
output link interface for this packet is interface 2.
• The router then internally forwards the packet to interface 2.
• The routing algorithm determines the values that are inserted into
the routers’ forwarding tables.
• The routing algorithm may be centralized (e.g., with an algorithm
executing on a central site and downloading routing information to
each of the routers) or decentralized (i.e., with a piece of the
distributed routing algorithm running in each router).
• In either case, a router receives routing protocol messages, which are
used to configure its forwarding table.
Virtual Circuit and Datagram
Networks
• Network layer can provide connectionless service or connection service
between two hosts.
• A network- layer connection service begins with handshaking between the
source and destination hosts; and a network-layer connectionless service
does not have any handshaking preliminaries.
• There are crucial differences from transport-layer connection-oriented and
connectionless services:
• In the network layer, these services are host-to-host services. transport
layer these services are process to- process services.
• Computer network architectures does not provide both connectionless
service or a host-to-host connection service at same time.
• Computer networks that provide only a connection service at the
network layer are called virtual-circuit (VC) networks
• Computer networks that provide only a connectionless service at
the network layer are called datagram networks.
Virtual
circuits
• Call setup,teardown for each call before data
can flow
• Each packet carries VC identifier (not destination host
address)
• Every routeron source-destination path maintains
“state” for each passing connection
• link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable
service)
Network Layer 4-16
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
1 3
2
VC number
interface
forwarding number
table in
router: Incoming VC # Outgoing interface Outgoing VC #
Incoming1interface 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
IP destination address in
arriving packet’s header
1
3
2
otherwise 3
longest prefix
matching
when looking for forwarding table entry for given
destination address, use longest address that
matches
prefix destination address.
Network Layer
Datagram