(5) The Network Layer

Download Report

Transcript (5) The Network Layer

South Valley University
Faculty of Science, Aswan
Mathematics Department
Computer Networks
BY
Dr. Alaa Sagheer
Chapter 5
The Network Layer
The Network Layer
- The network layer is concerned with getting packets from the
source all the way to the destination.
- It knows about the topology of the communication subnet (i.e.,
the set of all routers) and choose appropriate paths through it.
- It must also choose routes “carefully” to avoid overloading
some of the communication lines and routers while leaving
others idle.
- Finally, when the source and destination are in different
networks, it is up to the network layer to deal with them.
Network Layer Design Issues
•
•
•
•
Store-and-Forward Packet Switching
Services Provided to the Transport Layer
Implementation of Connectionless Service
Implementation of Connection-Oriented Service
Store-and-Forward Packet Switching (1)
This figure shows the context in which the network layer protocols
operate.
- The major components of the system are the carrier's equipment (routers
connected by transmission lines), shown inside the shaded oval, and the
customers' equipment, shown outside the oval. Host H1 is directly
connected to one of the carrier's routers, A, by a leased line. In contrast,
H2 is on a LAN with a router, F, owned and operated by the customer.
This router also has a leased line to the carrier's equipment.
- Routers on customer side are considered part of the subnet.
Store-and-Forward Packet Switching (2)
A host with a packet to send transmits it to the nearest
router, either on its own LAN or over a point-to-point link
to the carrier. The packet is stored there until it has fully
arrived so the checksum can be verified.
Then it is forwarded to the next router along the path until
it reaches the destination host, where it is delivered.
This mechanism is called store-and-forward
packet switching
Services to the Transport Layer (1)
The network layer provides services to the transport layer at
the network layer/transport layer interface. The designer
should consider the following goals when design it:
1. The services should be independent of the router
technology,
2. The transport layer should be shielded from the number,
type, and topology of the routers present.
3. The network addresses made available to the transport
layer should use a uniform numbering plan, even across
LANs and WANs.
Services to the Transport Layer (2)
The service should be connection-oriented or connectionless?
Two Camps:
- One camp argues that the routers' job is just moving
packets around and nothing else. In their view, the subnet
is inherently unreliable, no matter how it is designed.
- Therefore, the hosts should accept the fact that the
network is unreliable and do error control and flow
control themselves.
i.e.
- The network service should be connectionless, with just
SEND PACKET and RECEIVE PACKET,
- No packet ordering and flow control should be done,
- Each packet must carry the full destination address.
Services to the Transport Layer (2)
- The other camp argues that the subnet should provide a
reliable, connection-oriented service (telephone system is
an excellent guide)
- In this view, quality of service is the dominant factor, and
without connections in the subnet, quality of service is
very difficult to achieve, especially for real-time traffic
such as voice and video.
 EXAMPLES:
- The Internet offers connectionless network-layer service;
- ATM offer connection-oriented network-layer service.
 Please note that
- Quality-of-service is becoming more and more important,
- The Internet is evolving, it is starting to acquire properties normally
associated with connection-oriented service.
How Network Layer works?
According to the provided service:
- If connectionless service is offered, packets are injected into
the subnet individually and routed independently of each
other. No advance setup is needed. The packets are frequently
called datagrams and the subnet is called datagram subnet.
- If connection-oriented service is offered, a path from the
source router to the destination router must be established
before any data packets can be sent. This connection is called
a VC (virtual circuit), in analogy with the physical circuits
set up by the telephone system, and the subnet is called a
virtual-circuit subnet.
How Datagram Works? (1)
- Suppose that the process P1 has a long message for P2. It hands the
message to the transport layer with instructions to deliver it to process P2
on host H2,
- The transport layer code runs on H1, typically within the operating system.
It prepends a transport header to the front of the message and hands the
result to the network layer,
- The network layer breaks it into four packets, 1, 2, 3, and 4 and sends
each of them in turn to router A using some kind of point-to-point protocol,
- Every router has an internal table telling it where to send packets for each
possible destination. Each table entry is a pair consisting of a destination
and the outgoing line to use for that destination
How Datagram Works? (2)
- Each table entry is a pair consisting of a destination and the outgoing line
to use for that destination,
- Only directly-connected lines can be used…Example!
- Note that packets 1,2 and 3 follow the same route!
- Packet 4 changes the route!..Why?
…….May be Traffic Jam
The algorithm that manages the tables and makes the
routing decisions is called the Routing Algorithm.
How VC Works? (1)
For connection-oriented service, we need a virtual-circuit
subnet.
- The idea behind virtual circuits is to avoid having to choose a
new route for every packet sent,
- Instead, when a connection is established, a route from the
source machine to the destination machine is chosen as part of
the connection setup and stored in tables inside the routers,
- That route is used for all traffic flowing over the connection,
exactly the same way that the telephone system works,
- When the connection is released, the virtual circuit is also
terminated,
- With connection-oriented service, each packet carries an
identifier telling which virtual circuit it belongs to.
How VC Works? (2)
Consider that H3 also wants to establish a connection to H2. It
Here, host
H1 has established
with
H2. It the
is
chooses
connection
identifier connection
1 (because1 it
is host
initiating
remembered
the is
first
in each of the
routing
tables.
Theto
connection
andasthis
its entry
only connection)
and
tells the
subnet
first line the
of A's
tablecircuit.
says that
a packet
bearing
connection
establish
virtual
Noteif that
we have
a conflict
here
identifieralthough
1 comesAincan
from
H1,distinguish
it is to be sent
to router
C and
because
easily
connection
1 packets
givenH1connection
identifier
1. Similarly,
first entry
at C
from
from connection
1 packets
from H3,the
C cannot
do this.
routes
packetAto
E, alsoa with
connection
identifier
1. to the
For
thisthe
reason,
assigns
different
connection
identifier
outgoing traffic for the second connection.
Comparison between
Datagrams and VCs?
Left to YOU!
Routing Algorithms
•
•
•
•
Shortest Path Routing
Flooding
Hierarchical Routing
Broadcast Routing
Routing Algorithm- Intro (1)
The routing algorithm is that part of the network layer
software responsible for deciding which output line an
incoming packet should be transmitted on.
- If the subnet uses datagrams, this decision must be made
anew for every arriving data packet since the best route may
have changed since last time.
- If the subnet uses VC, routing decisions are made only when
a new virtual circuit is being set up.
Thereafter, data packets just follow the previously-established
route. The latter case is sometimes called session routing
because a route remains in force for an entire user session.
Routing Algorithm-Intro (2)
We should distinguish between Routing and Forwarding?
Router having two processes inside it.
- One of them handles each packet as it arrives, looking up the
outgoing line to use for it in the routing tables,
………This process is forwarding.
- The other process is responsible for filling in and updating
the routing tables.
- Certain properties are desirable in a routing algorithm:
correctness, simplicity, robustness, stability, fairness, and
optimality.
Routing Algorithm-Intro (3)
Certain properties are desirable in a routing algorithm
- Correctness..Simplicity..Robustness..Stability..Fairness..Opt
imality.
- “Robustness”: The routing algorithm should be able to cope with
changes in the topology and traffic without requiring all jobs in
all hosts to be aborted and the network to be rebooted every time
some router crashes.
- “Stability” is also an important goal for the routing algorithm to
be equilibrium,
Routing Algorithms-Intro (4)
Two kinds of RAs:
- Nonadaptive algorithms do not base their routing decisions
on measurements or estimates of the current traffic and
topology. Instead, the choice of the route to use to get from I to
J is computed in advance, off-line, and downloaded to the
routers when the network is booted. This procedure is
sometimes called static routing.
- Adaptive algorithms change their routing decisions to
reflect changes in the topology, and usually the traffic as
well. Adaptive algorithms differ in where they get their
information, when they change the routes and what metric
is used for optimization.. This procedure is called dynamic
routing.
Shortest Path Routing (1)
- The idea is to build a graph of the subnet, with each node of
the graph representing a router and each arc of the graph
representing a communication line (called link).
- To choose a route between a given pair of routers, the
algorithm just finds the shortest path between them on the
graph.
- One way of measuring path length is the number of hops
(ABC and ABE are equally long)
- Another metric is the geographic distance in kilometers,
(ABC much longer than ABE)
Shortest Path Routing (2)
- Using a test packet, each arc could be labeled with the
mean queuing and transmission delay..Then, the shortest
path is the fastest path rather than the path with the
fewest arcs or kilometers.
- In the general case, the labels on the arcs could be
computed as a function of the distance, bandwidth,
average traffic, communication cost, mean queue length,
measured delay, and other factors.
- Several algorithms for computing the shortest path
between two nodes of a graph are known. e.g. Dijkstra
(1959)…see the book!
Flooding-Static Algorithm
- Every incoming packet is sent out on every outgoing line
except the one it arrived on.
- Flooding generates infinite numbers of duplicate packets
unless some measures are taken to damp the process.
- One such measure is to have a hop counter contained in the
header of each packet, which is decremented at each hop, with
the packet being discarded when the counter reaches zero.
- Ideally, the hop counter should be initialized to the length of
the path from source to destination. If the sender does not
know how long the path is, it can initialize the counter to the
worst case, namely, the full diameter of the subnet.
Flooding-Static Algorithm
• Selective flooding, the routers do not send every incoming
packet out on every line, only on those lines that are going
approximately in the right direction.
• Flooding is not practical in most applications, but it does
have some uses. For example, in military applications, in
distributed database applications, in wireless networks,
Broadcast Routing
Sending a packet to all destinations simultaneously is called
broadcasting.
•One broadcasting method that requires no special features
from the subnet is for the source to simply send a distinct
packet to each destination.
• Flooding is another obvious candidate. Although flooding is
ill-suited for ordinary point-to-point communication.
• A third algorithm is multidestination routing. If this method
is used, each packet contains either a list of destinations or a
bit map indicating the desired destinations.
Broadcast Routing
• A fourth broadcast algorithm makes explicit use of the sink
tree for the router initiating the broadcast—or any other
convenient spanning tree for that matter. A spanning tree is a
subset of the subnet that includes all the routers but contains no
loops.
• Our last broadcast algorithm is an attempt to approximate the
behavior of the previous one, even when the routers do not
know anything at all about spanning trees. The idea, called
reverse path forwarding, is remarkably simple once it has been
pointed out.
Broadcast Routing
Reverse path forwarding. (a) A subnet. (b) a Sink tree. (c) The tree built by
reverse path forwarding.
An example of reverse path forwarding is shown in this figure.
Part (a) shows a subnet, part (b) shows a sink tree for router I of
that subnet, and part (c) shows how the reverse path algorithm
works.
Broadcast Routing
On the first hop, I sends packets to F, H, J, and N, as indicated
by the second row of the tree. Each of these packets arrives on
the preferred path to I and is so indicated by a circle around the
letter. On the second hop, eight packets are generated, two by
each of the routers that received a packet on the first hop. As it
turns out, all eight of these arrive at previously unvisited
routers, and five of these arrive along the preferred line. Of the
six packets generated on the third hop, only three arrive on the
preferred path (at C, E, and K); the others are duplicates. After
five hops and 24 packets, the broadcasting terminates,
compared with four hops and 14 packets had the sink tree been
followed exactly.
The Network Layer in the Internet
At the network layer, the Internet can be viewed as a collection
of subnetworks or Autonomous Systems (ASes) that are
interconnected.
The Network Layer in the Internet
- The glue that holds the whole Internet together is the
network layer protocol, IP (Internet Protocol).
- Its job is to provide a best-efforts way to transport
datagrams from source to destination, without regard to
whether these machines are on the same network or
whether there are other networks in between them.
The Network Layer in the Internet
Communication in the Internet works as follows:
The transport layer takes data streams and breaks them up into
datagrams,
Each datagram is transmitted through the Internet,
When all the pieces finally get to the destination machine, they
are reassembled by the network layer into the original
datagram,
This datagram is then handed to the transport layer, which
inserts it into the receiving process' input stream.
The IP Protocol(1)
An IP datagram consists of a header part and a text part.
The header format is transmitted in big-endian order: from left
to right, with the high-order bit of the Version field going first.
The IP Protocol(1)
- The Version field keeps track of which version of the protocol
the datagram belongs to. By including the version in each
datagram, it becomes possible to have the transition between
versions take years, with some machines running the old version
and others running the new one.
- Since the header length is not constant, a field in the header,
IHL, is provided to tell how long the header is, in 32-bit words.
- The Type of service field is one of the few fields that has
changed its meaning over the years. It was and is still intended
to distinguish between different classes of service.
Various combinations of reliability and speed are possible:
For digitized voice, fast delivery beats accurate delivery,
For file transfer, error-free transmission is more important than
fast transmission.
The IP Protocol(1)
- The Total length includes everything in the datagram—both
header and data.
- The Identification field is needed to allow the destination host
to determine which datagram a newly arrived fragment belongs
to. All the fragments of a datagram contain the same
Identification value.
- DF stands for (Don't Fragment). It is an order to the routers
not to fragment the datagram because the destination is
incapable of putting the pieces back together again.
- MF stands for (More Fragments). It is needed to know when
all fragments of a datagram have arrived.
- The Fragment offset tells where in the current datagram this
fragment belongs.
The IP Protocol(1)
- The Time to live field is a counter used to limit packet
lifetimes. It is supposed to count time in seconds, allowing a
maximum lifetime of 255 sec.
- When the network layer has assembled a complete datagram,
it needs to know what to do with it. The Protocol field tells it
which transport process to give it to.
- The Header checksum verifies the header only. Such a
checksum is useful for detecting errors generated by bad
memory words inside a router.
- The Source address and Destination address indicate the
network number and host number.
The IP Protocol(1)
- The Time to live field is a counter used to limit packet
lifetimes. It is supposed to count time in seconds, allowing a
maximum lifetime of 255 sec.
- When the network layer has assembled a complete datagram,
it needs to know what to do with it. The Protocol field tells it
which transport process to give it to.
- The Header checksum verifies the header only. Such a
checksum is useful for detecting errors generated by bad
memory words inside a router.
- The Source address and Destination address indicate the
network number and host number.
The IP Protocol (2)
- The Options field was designed to provide an escape to allow
subsequent versions of the protocol to include information not
present in the original design, to permit experimenters to try out
new ideas, and to avoid allocating header bits to information
that is rarely needed.
Originally, five options were defined, as follows:
The IP Protocol (2)
1. The Security option tells how secret the information is.
2. The Strict source routing option gives the complete path
from source to destination as a sequence of IP addresses.
3. The Loose source routing option requires the packet to
traverse the list of routers specified, and in the order
specified, but it is allowed to pass through other routers on
the way.
4. The Record route option tells the routers along the path to
append their IP address to the option field.
5. Finally, the Timestamp option is like the Record route
option, except that in addition to recording its 32-bit IP
address, each router also records a 32-bit timestamp. This
option, too, is mostly for debugging routing algorithms.
IP Addresses
- Every host and router on the Internet has an IP address,
which encodes its network number and host number.
- No two machines on the Internet have the same IP
address.
- IP addresses were divided into the five categories, this
allocation has come to be called classful addressing.
IP Addresses
Here, the class A, B, C, and D formats allow for up to 128
networks with 16 million hosts each, 16,384 networks with up to
64K hosts, and 2 million networks with up to 256 hosts each.
Addresses beginning with 1111 are reserved for future use.
Network numbers are managed by a nonprofit corporation called
ICANN (Internet Corporation for Assigned Names and
Numbers) to avoid conflicts.
IP Addresses (2)
The lowest IP address is 0.0.0.0 and the highest is
255.255.255.255.
The values 0 and -1 have special meanings, The value 0 means
this network or this host. The value of -1 is used as a broadcast
address to mean all hosts on the indicated network.
IP Addresses (2)
-The IP address 0.0.0.0 is used by hosts when they are being
booted.
- IP addresses with 0 as network number refer to the current
network. These addresses allow machines to refer to their own
network without knowing its number.
- The address consisting of all 1s allows broadcasting on the
local network.
- The addresses with a proper network number and all 1s in the
host field allow machines to send broadcast packets to distant
LANs anywhere in the Internet.
- Finally, all addresses of the form 127.xx.yy.zz are reserved for
loopback testing.