0% found this document useful (0 votes)
2 views

Module 3 Part 1

The network layer facilitates host-to-host communication by performing forwarding and routing functions, with each router and host containing a portion of the network layer. Forwarding transfers packets within a router, while routing determines the paths packets take across multiple routers. The network layer can operate in either connection-oriented (virtual circuit) or connectionless (datagram) modes, with distinct characteristics for each service type.

Uploaded by

leojoychan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Module 3 Part 1

The network layer facilitates host-to-host communication by performing forwarding and routing functions, with each router and host containing a portion of the network layer. Forwarding transfers packets within a router, while routing determines the paths packets take across multiple routers. The network layer can operate in either connection-oriented (virtual circuit) or connectionless (datagram) modes, with distinct characteristics for each service type.

Uploaded by

leojoychan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Network

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

Network Layer 4-17


VC forwarding
table 12 22 32

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
… … … …

VC routers maintain connection state


information! Network Layer 4-18
Virtual circuit
setup
Virtual circuit
Phases
• There are three identifiable phases in a virtual circuit:
1. VC setup
2. Data transfer.
3. VC teardown.
Virtual setup
• VC setup. During the setup phase, the sending transport layer
contacts the network layer, specifies the receiver’s address,
and waits for the network to set up the VC.

• The network layer determines the path between sender and


receiver, that is, the series of links and routers through which
all packets of the VC will travel.

• The network layer also determines the VC number for each


link along the path.
• Finally, the network layer adds an entry in the forwarding
table in each router
Setup request in a virtual circuit
Acknowledgment Phase
VC Data transfer.
• Data transfer.once the VChas been established, packets
can begin to flow along the VC.
VC Data Transfer
VC teardown.
• VC teardown. This is initiated when the sender (or
receiver) informs the network layer of its desire to
terminate the VC.

• The network layer will then typically inform the end


system on the other side of the network of the call
termination and update the forwarding tables in each of
the packet routers on the path to indicate that the VC
no longer exists.
Datagram networks
• no call setup at network layer
• routers: no state about end-to-end connections
– 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-13


Datagram forwarding table
4 billion IP addresses,
routing algorithm
so rather than list
individual destination
local forwarding table
address list range of
dest address output link
address-range 1 3
addresses (aggregate
address-range 2 2 table entries)
address-range 3 2
address-range 4 1

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

Network Layer 4-14


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-15


Datagram forwarding table
• With this style of forwarding table, the router matches a
prefix of the packet’s destination address with the entries in
the table; if there’s a match, the router forwards the packet to
a link associated with the match.

• For example, suppose the packet’s destination address is


11001000 00010111 00010110 10100001; because the 21-bit
prefix of this address matches the first entry in the table, the
router forwards the packet to link interface 0.

• If a prefix doesn’t match any of the first three entries,


then the router forwards the packet to interface 3.
Datagram forwarding table
• it is possible for a destination address to match more
than one entry. For example, the first 24 bits of the
address 11001000 00010111 00011000 10101010 match
the second entry in the table, and the first 21 bits of the
address match the third entry in the table.

• When there are multiple matches, the router uses the


longest prefix matching rule; that is, it finds the
longest matching entry in the table and forwards the
packet to the link interface associated with the longest
prefix match.
Longest prefix matching

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

Network Layer
Datagram

• Eachpacket treated • Up to receiver to re-order


independently of all others packets and recover from
• Packets cantake any missing packets
practical route • The connecting switches
• Datagram switching is are not keeping information
done at network layer
about connection state hence
• These switches are called it is also
routers. connectionless networks
• Packets may arrive out of order • No setup and
teardown
phases.
• Packets may go missing
Datagram network
Route
r• A router is a networking device that forwards data packets between
computer networks.
• Routers perform the traffic directing functions on the Internet.
• A packet is typically forwarded from one router to another
router through the networks that constitute an internetwork
(e.g. the Internet) until it reaches its destination node.
• A router is connected to two or more data lines from different IP
networks.
• When a data packet comes in on one of the lines, the router reads
the network address information in the packet header to determine
the ultimate destination. Then, using information in its routing table
or routing policy, it directs the packet to the next network on its
journey.
The Internet Protocol (IP)
• Forwarding and Addressing in the Internet
• Internet addressing and forwarding are important components of the
Internet Protocol (IP). There are two versions of IP in use today.
• IP protocol version 4, which is usually referred to simply as IPv4
• IP version 6
• Internet’s network layer has three major components.
• The first component is the IP protocol.
• The second major component is the routing component, which determines
the path a datagram follows from source to destination.
• The final component of the network layer is a facility to report errors in
datagrams and respond to requests for certain network-layer information.
Datagram Format
• A network-layer packet is referred to as a datagram.
• The datagram plays a central role in the Internet
IPv4 datagram
format
• Version number. These 4 bits specify the IP protocol version of the
datagram.By looking at the version number, the router can determine how
to interpret the remainder of the IP datagram.
• Header length. These 4 bits are needed to determine where in the IP
datagram the data actually begins. Most IP datagrams, the typical IP
datagram has a 20-byte header.
• Type of service. The type of service (TOS) bits were included in the IPv4
header to allow different types of IP datagrams to be distinguished from
each other. For example, it might be useful to distinguish real-time
datagrams (such as those used by an IP telephony application) from non-
real-time traffic (for example, FTP).
• Datagram length. This is the total length of the IP datagram (header plus
data), measured in bytes. Since this field is 16 bits long, the theoretical
maximum size of the IP datagram is 65,535 bytes. However, datagrams are
rarely larger than 1,500 bytes.
• Identifier, flags, fragmentation offset. These three fields have to
do with so-called IP fragmentation
• Time-to-live. The time-to-live (TTL) field is included to ensure that
datagrams do not circulate forever in the network. This field is
decremented by one each time the datagram is processed by a
router. If the TTL field reaches 0, the datagram must be dropped.
• Protocol. This field is used only when an IP datagram reaches its final
destination. The value of this field indicates the specific transport-
layer protocol.
• Header checksum. The header checksum aids a router in detecting bit
errors in a received IP datagram. The header checksum is computed
by treating each 2 bytes in the header as a number and summing
these numbers using 1s complement arithmetic.
• Source and destination IP addresses. When a source creates a
datagram, it inserts its IP address into the source IP address field and
inserts the address of the ultimate destination into the destination IP
address field.
• Options. The options fields allow an IP header to be extended.
• Data (payload). The data field of the IP datagram contains the
transport-layer segment (TCP or UDP) to be delivered to the
destination.

You might also like