Anda di halaman 1dari 40

Network Layer

What is Network Layer?


• The network layer is concerned with getting packets from the source all the
way to the destination.
• The packets may require to make many hops at the intermediate routers
while reaching the destination.
• This is the lowest layer that deals with end to end transmission.
• In order to achieve its goals, the network layer must know about the
topology of the communication network.
• It must also take care to choose routes to avoid overloading of some of the
communication lines while leaving others idle.
• The network layer-transport layer interface frequently is the interface
between the carrier and the customer, that is the boundary of the subnet.
Functions of Network Layer
• Routing
• Inter-networking
• Congestion Control
Routing
• The process of transferring packets received from the Data Link Layer
of the source network to the Data Link Layer of the correct
destination network is called routing.
• Involves decision making at each intermediate node on where to send
the packet next so that it eventually reaches its destination.
• The node which makes this choice is called a router.
• For routing we require some mode of addressing which is recognized
by the Network Layer.
• This addressing is different from the MAC layer addressing.
Internetworking
• The network layer is the same across all physical networks (such as
Token-Ring and Ethernet).
• Thus, if two physically different networks have to communicate, the
packets that arrive at the Data Link Layer of the node which connects
these two physically different networks, would be stripped of their
headers and passed to the Network Layer.
• The network layer would then pass this data to the Data Link Layer of
the other physical network.
Congestion Control
• If the incoming rate of the packets arriving at any router is more than the
outgoing rate, then congestion is said to occur.
• Congestion may be caused by many factors.
• If suddenly, packets begin arriving on many input lines and all need the same output
line, then a queue will build up.
• If there is insufficient memory to hold all of them, packets will be lost.
• But even if routers have an infinite amount of memory, congestion gets worse,
because by the time packets reach to the front of the queue, they have already
timed out (repeatedly), and duplicates have been sent.
• All these packets are dutifully forwarded to the next router, increasing the load all
the way to the destination.
• Another reason for congestion are slow processors.
• If the router's CPUs are slow at performing the bookkeeping tasks required of them,
queues can build up, even though there is excess line capacity.
• Similarly, low-bandwidth lines can also cause congestion
Addressing Scheme
• IP addresses are of 4 bytes and consist of :
• The network address, followed by
• The host address
• The first part identifies a network on which the host resides and the second part
identifies the particular host on the given network.
• Some nodes which have more than one interface to a network must be assigned
separate internet addresses for each interface.
• This multi-layer addressing makes it easier to find and deliver data to the destination.
• A fixed size for each of these would lead to wastage or under-usage that is either there
will be too many network addresses and few hosts in each (which causes problems for
routers who route based on the network address) or there will be very few network
addresses and lots of hosts (which will be a waste for small network requirements).
• Thus, we do away with any notion of fixed sizes for the network and host addresses.
Classification of Networks
• Large Networks : 8-bit network address and 24-bit host address.
• There are approximately 16 million hosts per network and a maximum of 126 ( 2^7 - 2 ) Class
A networks can be defined.
• The calculation requires that 2 be subtracted because 0.0.0.0 is reserved for use as the
default route and 127.0.0.0 be reserved for the loop back function.
• Moreover each Class A network can support a maximum of 16,777,214 (2^24 - 2) hosts per
network.
• The host calculation requires that 2 be subtracted because all 0's are reserved to identify the
network itself and all 1s are reserved for broadcast addresses.
• The reserved numbers may not be assigned to individual hosts.
• Medium Networks : 16-bit network address and 16-bit host address.
• There are approximately 65000 hosts per network and a maximum of 16,384 (2^14) Class B
networks can be defined with up to (2^16-2) hosts per network.
• Small networks : 24-bit network address and 8-bit host address.
• There are approximately 250 hosts per network.
IP Addresses
 An IP address is an address used to uniquely identify a device on an
IP network.
 The address is made up of 32 binary bits which can be divisible into a
network portion and host portion with the help of a subnet mask.
 32 binary bits are broken into four octets (1 octet = 8 bits)
 Dotted decimal format (for example, 172.16.81.100)
IP Address Classes
IP Addressing
• There are five forms of IP addresses:
Class A :126 networks, each can have up to (16M-2) nodes.
(1.0.0.0 - 126.0.0.0)
Class B: (16K-2) networks, each can have up to (64K-2) nodes
(127.0.0.0 - 191.255.0.0)
Class C: (2M-2) networks, each can have up to 254 nodes.
(192.0.0.0 - 223.255.255.0)
Class D: a multicast address.
(224.0.0.0 - 240.0.0.0)
Class E: reserved for future use.
(241.0.0.0 - 248.0.0.0)
IP address format
IP Address Classes
• Class A: The first octet is the network portion. Octets 2, 3, and 4 are
for subnets/hosts
• Class B: The first two octets are the network portion. Octets 3 and 4
are for subnets/hosts
• Class C: The first three octets are the network portion. Octet 4 is for
subnets/hosts
Private Address Range
Address Class Reserved Address Space
Class A 10.0.0.0 - 10.255.255.255
Class B 172.16.0.0 - 172.31.255.255
Class C 192.168.0.0 - 192.168.255.255
Network Masks
• Distinguishes which portion of the address
identifies the network and which portion of the
address identifies the node.
• Default masks:
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0
Subnetting
 Creates multiple logical networks that exist within a single Class A, B,
or C network.
 If you do not subnet, you will only be able to use one network from
your Class A, B, or C network, which is unrealistic
 Each data link on a network must have a unique network ID, with
every node on that link being a member of the same network
Benefits of Subnetting
1) Reduced network traffic
2) Optimized network performance
3) Simplified management
4) Facilitated spanning of large geographical distances
How to create subnets
 Determine the number of required network IDs:
One for each subnet
One for each wide area network connection
 Determine the number of required host IDs per subnet:
One for each TCP/IP host
One for each router interface
 Based on the above requirements, create the following:
One subnet mask for your entire network
A unique subnet ID for each physical segment
A range of host IDs for each subnet
Subnetting a Class A/B/C Address
• How many subnets does the chosen subnet mask produce?
• How many valid hosts per subnet are available?
• What are the valid subnets?
• What’s the broadcast address of each subnet?
• What are the valid hosts in each subnet?
Routing
• Routing is the process of forwarding of a packet in a network so that it reaches its
intended destination.
• The main goals of routing are:
• Correctness: The routing should be done properly and correctly so that the packets may reach
their proper destination.
• Simplicity: The routing should be done in a simple manner so that the overhead is as low as
possible. With increasing complexity of the routing algorithms the overhead also increases.
• Robustness: Once a major network becomes operative, it may be expected to run continuously for
years without any failures. The algorithms designed for routing should be robust enough to handle
hardware and software failures and 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 rebooted every time
some router goes down.
• Stability: The routing algorithms should be stable under all possible circumstances.
• Fairness: Every node connected to the network should get a fair chance of transmitting their
packets. This is generally done on a first come first serve basis.
• Optimality: The routing algorithms should be optimal in terms of throughput and minimizing
mean packet delays. Here there is a trade-off and one has to choose depending on his suitability.
Routing Algorithm
• The routing algorithm is that part of the network layer software
responsible for deciding which output line an incoming packet should
be transmitted on.
• Routing algorithms can be grouped into two major classes:
• Non adaptive
• Adaptive routing algorithms
Non Adaptive algorithms
• Non adaptive algorithms do not base their routing decisions on
estimates of the current traffic and topology.
• Instead, the choice of the route computed in advance, off-line, and
downloaded to the routers when the network is booted.
• This is also known as static routing.
• The following are some Non Adaptive (Static) routing algorithms;
• Shortest Path Routing
• Flooding
Shortest Path Routing
• build a graph of the subnet, with each node of the graph representing
a router and each arc of the graph representing a link.
• the algorithm just finds the shortest path between two node for
finding the route
Flooding
• Every incoming packet is sent out on every outgoing line except the one it
arrived on.
• Generates vast numbers of duplicate packets
• A hop counter contained in the header of each packet.
• An alternative technique for damming the flood is to keep track of which
packets have been flooded, to avoid sending them out a second time.
• The source router put a sequence number in each packet it receives from
its hosts.
• Each router then needs a list per source router telling which sequence
numbers originating at that source have already been seen. If an incoming
packet is on the list, it is not flooded.
Adaptive algorithms
• Routing decisions to reflect changes in the topology, and the traffic as well.
• Adaptive algorithms differ in where they get their information
• when they change the routes(e.g., locally, from adjacent routers, or from all
routers),
• and what metric is used for optimization (e.g., distance, number of hops, or
estimated transit time).
• These get their routing information from adjacent routers or from all
routers.
• The optimization parameters are the distance, number of hops and
estimated transit time.
• The following are some Adaptive (Dynamic) routing algorithms
• Distance Vector Routing
• Link State Routing
Distance Vector Routing
• Each router knows only address/cost of neighbors
• Calculate routing table of next hop information for each destination at each
router
• Tell neighbors about learned distances to all destinations
• Each router maintains a routing table indexed by, and containing one entry
for, each router in the subnet.
• This entry contains two parts:
• the preferred outgoing line to use for that destination and
• an estimate of the time or distance to that destination.
• The metric used might be number of hops, time delay in milliseconds, total
number of packets queued along the path, or something similar.
Link State Routing
• Distance vector routing was used in the ARPANET until 1979, when it
was replaced by link state routing.
• Two primary problems of DVR
• it did not take line bandwidth into account when choosing routes.
• the algorithm often took too long to converge (the count-to-infinity problem).
The idea behind link state routing
• Each router must do the following:
• Discover its neighbors and learn their network addresses.
• Measure the delay or cost to each of its neighbors.
• Construct a packet telling all it has just learned.
• Send this packet to all other routers.
• Compute the shortest path to every other router.
1. Learning about the Neighbors
• When a router is booted, its learn who its neighbors are.
• It accomplishes by sending a special HELLO packet on each point-to-
point line.
• The router on the other end is send back a reply telling who it is.
• These names must be globally unique because when a distant router
later hears that three routers are all connected to F, it is essential that
it can determine whether all three mean the same F.
2. Measuring Line Cost
• Each router to know, or at least have a reasonable estimate of, the
delay to each of its neighbors.
• The most direct way to determine this delay is to send over the line a
special ECHO packet that the other side is required to send back
immediately.
• By measuring the round-trip time and dividing it by two, the sending
router can get a reasonable estimate of the delay.
3. Building Link State Packets
• The packet starts with the identity of the sender, followed by a
sequence number and age , and a list of neighbors.
• For each neighbor, the delay to that neighbor is given.
4. Distributing the Link State Packets
• The fundamental idea is to use flooding to distribute the link state packets.
• To keep the flood in check, each packet contains a sequence number that is
incremented for each new packet sent.
• Routers keep track of all the (source router, sequence) pairs they see.
• When a new link state packet comes in, it is checked against the list of
packets already seen.
• If it is new, it is forwarded on all lines except the one it arrived on. If it is a
duplicate, it is discarded.
• If a packet with a sequence number lower than the highest one seen so far
ever arrives, it is rejected as being obsolete since the router has more
recent data.
5. Computing the New Routes
• Once a router has accumulated a full set of link state packets, it can
construct the entire subnet graph because every link is represented.
• Every link is, in fact, represented twice, once for each direction. The
two values can be averaged or used separately.
• Now Dijkstra's algorithm can be run locally to construct the shortest
path to all possible destinations.
• The results of this algorithm can be installed in the routing tables, and
normal operation resumed.
Hierarchical Routing
• As networks grow in size, the router routing tables grow
proportionally.
• router memory consumed by ever-increasing tables,
• more CPU time is needed to scan them
• more bandwidth is needed to send status reports
• so the routing will have to be done hierarchically, as it is in the
telephone network.
Hierarchical Routing
• the routers are divided into regions, with each router knowing all the
details about how to route packets to destinations within its own
region, but knowing nothing about the internal structure of other
regions.
• When different networks are interconnected, it is natural to regard
each one as a separate region in order to free the routers in one
network from having to know the topological structure of the other
ones.
Congestion Control Algorithms
• When too many packets are present in (a part of) the
subnet, performance degrades. This situation is called
congestion.
• If all of a sudden, streams of packets begin arriving on
three or four input lines and all need the same output
line.
• Slow processors
General Principles of Congestion Control
• On control theory point of view divide all solutions into two groups:
open loop and closed loop.
• Open loop solutions attempt to solve the problem by good design
• closed loop solutions are based on the concept of a feedback loop
open-loop control
• deciding when to accept new traffic,
• deciding when to discard packets and which ones, and
• making scheduling decisions at various points in the network.
• All of these decisions are without regard to the current state of the
network
closed loop solutions
This approach has three parts when applied to congestion control:
• Monitor the system to detect when and where congestion occurs.
• Pass this information to places where action can be taken.
• Adjust system operation to correct the problem.

Anda mungkin juga menyukai