Вы находитесь на странице: 1из 97

The Network Layer

Network Layer
Recall:
The network layer is responsible for the routing of packets The network layer is responsible for congestion control

Contents
Connection-Oriented and Connectionless Service The IP Protocol IP-Support Protocols Routing Algorithms Congestion Control

1. Connection-Oriented and Connectionless Service


Network layers can offer two types of service to the transport layer:
Connection-oriented service
Network layer provides the Transport layer with a reliable service: all packets will be delivered (flow control), insequence delivery Connection setup required before communication begins

Connectionless service
No guarantee No prior connection setup required; packets are stored and forwarded one at a time by IMPs

1.1 Connection-Oriented Service


How to provide connection-oriented service:
Set up a route (virtual circuit) between source and destination That route is used for all traffic flowing over the virtual circuit IMP maintains an internal table to tell which outgoing line to forward packet on for each active virtual circuit Packets must contain a virtual circuit number so that IMP can figure out how to forward them

Connection-Oriented Service: Analogy


Public Telephone Network
Set up a virtual circuit (dial a number) Transmit data on the circuit (conversation) Close down the virtual circuit (hang up)

Two users are provided with the illusion of a dedicated point-to-point channel Information is delivered to the receiver in the same order in which it is transmitted by the sender

1.2 Connectionless Service


How to provide connectionless service:
Send the packet into the network and allow the network to forward it however it likes IMPs maintain routing tables to look up the next IMP for each arriving packet Each packet must contain a destination address so the IMPs can make routing decisions

Connectionless Service: An Analogy


Postal service:
Each packet (letter) is transported as an individual entity Each packet (letter) must carry the complete destination address If a packet (letter) is lost, error control is the users responsibility Packets (letters) do not necessarily arrive in the order sent

1.3 Comparison between Connectionless and Connection-Oriented Services


Connection Setup Procedure:
Connection-oriented service
Explicit setup and tear-down required For short transaction oriented communication, the delay of connection setup may be expensive

Connectionless service
No setup or tear-down required For long continuous communication, the overhead of packet headers may be expensive

Comparison (contd)
Header Overhead
Connection-oriented service
Only the virtual circuit number

Connectionless service
The full destination address is required

Comparison (contd)
Message Sequence:
Connection-oriented service
Sequence automatically maintained

Connectionless service
Destination may have to re-sequence out-ofsequence messages

Comparison (contd)
Robustness
Connection-oriented service
Vulnerable: If IMP crashes, all virtual circuits passing through it have to be aborted and reestablished

Connectionless service
Robust: If IMP goes down, only hosts whose packets were queued at the time of the crash are lost. Other packets will be rerouted dynamically.

Comparison (contd)
Guaranteed service:
Connection-oriented service
Can provide guarantees on the delays and throughput of packets being sent

Connectionless service
It is very difficult to provide guarantees for timely packet delivery

Summary
Connection-oriented service
Is useful for applications which prefer insequence delivery of packets. It is also preferable for applications that require guaranteed service

Connectionless service
Provides flexibility in the routing and handling of individual packets and is robust in the face of IMP crashes

2. The Internet Protocol (IP)


Provides delivery of packets from one host in the Internet to any other host in the Internet, even if the hosts are on different networks Internet packets are often called datagrams and may be up to 64 kilobytes in length (although they are typically much smaller) Internet IMPs are known as routers and they operate in a connectionless mode

2.1 IP Packet Format


32 bits Ver. IHL Type of Serv.
DM F F

Total Length Fragment Offset Header checksum

Identification Time to Live Protocol

Source address Destination address Options (0 or more 32-bit words)

Data (0 to 65,515 bytes)

IP Packet Fields
Version
The IP version number (currently 4)

IHL
IP Header Length in 32-bit words

Type of Service
Contains priority information, rarely used

Total Length
The total length of the datagram in bytes Includes header

IP Packet Fields (contd)


Identification
When an IP packet is segmented into multiple fragments, each fragment is given the same identification This field is used to reassemble fragments

DF
Dont Fragment

MF
More Fragments When a packet is fragmented, all fragments except the last one have this bit set

IP Packet Fields (contd)


Fragment offset
The fragments position within the original packet

Time to Live
Hop count, decremented each time the packet reaches a new router When hop count = 0, packet is discarded

Protocol
Identifies which transport layer protocol is being used for this packet

Header Checksum
Verifies the contents of the IP header Not polynomial-based

IP Packet Fields (contd)


Source and Destination Addresses
Uniquely identify sender and receiver of the packet

Options
Up to 40 bytes in length Used to extend functionality of IP Examples: source routing, security, record route

2.2 IP Addresses
32 bits long (4 bytes) Notation:
Each byte is written in decimal in MSB order, separated by decimals Example: 128.195.1.80 0.0.0.0 (lowest) to 255.255.255.255 (highest)

Address Classes
Class A, B, C, D, E Loopback Broadcast

IP Address Classes
Class A 0 Net 32 bits Type of Serv. Host

B C D E

10 110 1110 11110

Net Net Multicast address Reserved

Host Host

IP Address Classes
Class A:
For very large organizations 16 million hosts allowed

Class B:
For large organizations 65 thousand hosts allowed

Class C
For small organizations 255 hosts allowed

Class D
Multicast addresses No network/host hierarchy

Class E
reserved

Loopback
127.xx.yy.zz (127.anything) is reserved for loopback testing packets sent to this address are not put out onto the wire; they are processed locally and treated as incoming packets.

Broadcast
all 1s

IP Address Hierarchy
Note that Class A, Class B, and Class C addresses only support two levels of hierarchy Each address contains a network and a host portion, meaning two levels of hierarchy However, the host portion can be further split into subnets by the address class owner This allows for more than 2 levels of hierarchy

Subnetting
Example: Class B address with 8-bit subnetting 16 bits Network id Example Address:
Class B 10 Net

8 bits Subnet id .24

8 bits Host id .8

165.230

32 bits Host

Subnet Masks
Subnet masks allow hosts to determine if another IP address is on the same subnet or the same network 16 bits Network id 1111111111111111 Mask: 255.255 8 bits Subnet id 11111111 .255 8 bits Host id 00000000 .0

Subnet Masks (contd)


Assume IP addresses A and B share subnet mask M. Are IP addresses A and B on the same subnet? 1. Compute (A and M). (Boolean AND) 2. Compute (B and M). (Boolean AND) 3. If (A and M) = (B and M) then A and B are on the same subnet. Example: A and B are class B addresses A = 165.230.82.52 Same network? B = 165.230.24.93 Same subnet? M = 255.255.255.0

Note
0 AND 0 = 0 0 AND 1 = 1 AND 0 = 0 1 AND 1 = 1

Thus, computing (A and M) results in


Network ID = Network ID of A Subnet ID = Subnet ID of A Host ID = 0

Why do we need subnet mask?


When subnetting is introduced, a routing table is modified to include (this-network, subnet, 0) and (this-network, this-subnet, host)

Routing table
network ID this network this network this network this network subnet ID this subnet this subnet different subnet different subnet host ID A B 0 0 0

different network 0

Subnet mask helps quickly identifying which routing table entry to look up

IP Addressing
How does an ISP get block of addresses?
ICANN: Internet Corporation for Assigned

Names and Numbers


allocates addresses manages DNS assigns domain names, resolves disputes

2.3 IP Routing
How do you get a packet from one network to another?

?
A B C D W X Y Z

IP Routing

(contd)

Answer: with a router (or a series of routers)


Case 1: Single hop
A B C D

R
W X Y Z

Case 2: Multi-hop
A B C D

Network Cloud

R
W X Y Z

Example
R1
N1 N2

R2
N3

R3
N4

Dest Next hop

Routing table @ R2

N1 N2 N3 N4

R1 Deliver directly Deliver directly R3

Actual routing table contains IP addresses, Flags indicating type of entries, net mask etc. (see Stevens pg. 113, sect 9.2)

Searching the routing table


First, search for a matching host address
Flag H is set

Second, search for a matching network address


Need to know the number of bits to use for network ID

Third, search for a default entry


Execute netstat -rn on your machine and find the contents of the routing table

Default entry allows for a single entry for a list of entries that have the same next-hop value

3. IP Support Protocols
ARP RARP ICMP

3.1 ARP
Address Resolution Protocol Returns a MAC sublayer address when given an Internet (IP) address Commonly used in broadcast LANs so that two hosts can communicate using IP addresses instead of MAC sublayer addresses

MAC Layer Ethernet Frame Format


Multicast bit Destination
(6 bytes)

Source
(6 bytes)

Length (2 bytes) Data


(46-1500 bytes)

Pad Frame Check Seq.


(4 bytes)

IP Address Classes
Class A 0 Net 32 bits Type of Serv. Host

B C D E

10 110 1110 11110

Net Net Multicast address Reserved

Host Host

ARP (contd)
ARP packet containing 128.195.1.38? ARP

Ethernet Address: 05:23:f4:3d:e1:04 IP Address: 128.195.1.20 Wants to transmit to 128.195.1.38

Ethernet Address: 12:04:2c:6e:11:9c IP Address: 128.195.1.122 Ignored

Ethernet Address: 98:22:ee:f1:90:1a IP Address: 128.195.1.38 Answered

ARP (contd)
ARP response packet containing 98:22:ee:f1:90:1a Repl

Ethernet Address: 05:23:f4:3d:e1:04 IP Address: 128.195.1.20

Ethernet Address: 12:04:2c:6e:11:9c IP Address: 128.195.1.122

Ethernet Address: 98:22:ee:f1:90:1a IP Address: 128.195.1.38

3.2 RARP
Reverse Address Resolution Protocol RARP performs the inverse action of ARP RARP returns an IP address for a given MAC sublayer address Operationally, RARP is the same as ARP

3.3 ICMP
Internet Control Message Protocol Handles special Internet control functions Responsibilities:
Reporting unreachable destinations Reporting IP packet header problems Reporting routing problems Reporting echoes (pings)

ICMP
Protocol for error detection and reporting
tightly coupled with IP, unreliable

ICMP messages delivered in IP packets ICMP functions:


Announce network errors Announce network congestion Assist trouble shooting Announce timeouts

ICMP MSG
IP header Source, Destination Address, TTL, ... ICMP MSG Message type, Code, Checksum, Data Message type examples (Figure 6.3 in Stevens book): 0 (8) echo request (reply) 3 destination unreachable 4 source quench 11 time exceeded

Specific uses of ICMP


Echo request/reply
Can be used to check if a host is alive

Address mask request/reply


Learn the subnet mask

Destination unreachable
Invalid address and/or port

Source quench
choke packet

TTL expired
Routing loops, or too far away

Ping
Uses ICMP echo request/reply Source sends ICMP echo request message to the destination address
Echo request packet contains sequence number and timestamp

Destination replies with an ICMP echo reply message containing the data in the original echo request message Source can calculate round trip time (RTT) of packets If no echo reply comes back then the destination is unreachable

Ping (contd)
A
R1 R2 R3

Echo request

Time
Echo reply

Traceroute
Traceroute records the route that packets take A clever use of the TTL field When a router receives a packet, it decrements TTL If TTL=0, it sends an ICMP time exceeded message back to the sender To determine the route, progressively increase TTL
Every time an ICMP time exceeded message is received, record the senders (routers) address Repeat until the destination host is reached or an error message occurs

Traceroute (contd)
Te = Time exceeded Pu = Port unreachable

R1
TTL=1, Dest = B, port = invalid

R2

R3

Te (R1)
TTL=2, Dest = B

Time

Te (R2)
TTL=3, Dest = B

Te (R3)
TTL=4, Dest = B

Pu (B)

4. Routing Algorithms
An IMP executes a routing algorithm to decide which output line an incoming packet should be transmitted on In connection-oriented service, the routing algorithm is performed only during connection setup In connectionless service, the routing algorithm is performed as each packet arrives

Routing Algorithms (contd)


Two types of routing algorithms:
Non-Adaptive Routing Algorithms Adaptive Routing Algorithms Hierarchical Routing is used to make these algorithms scale to large networks

4.1 Non-Adaptive Routing Algorithms


Non-adaptive routing algorithms do not base their routing decisions on the current state of the network Examples:
Shortest Path Routing Flooding

4.1.1 Shortest Path Routing


For a pair of communicating hosts, there is a shortest path between them Shortness may be defined by:
Number of IMP hops Geographic distance Link delay

Shortest Path
What is the shortest path between A and F?
3
A B

2 4
D

1 2
E

2
C

Edge Weight (Distance)

Computing the Shortest Path


Dijkstras Shortest Path Algorithm:
Step 1: Draw nodes as circles. Fill in a circle to mark it as a permanent node. Step 2: Set the current node equal to the source node Step 3: For the current node: Mark the cumulative distance from the current node to each non-permanent adjacent node. Also mark the name of the current node. Erase this marking if the adjacent node already has a shorter cumulative distance marked Mark the non-permanent node with the shortest listed cumulative distance as permanent and set the current node equal to it. Repeat step 3 until all nodes are marked permanent.

Dijskstras Shortest Path Algorithm


Example

B
2 2

7 3

C
3

A
1 6

F
2 2

Place Fig.5-6 from Tanenbaum p.349 here.

Shortest Path Routing (contd)


Non-adaptive, if:
geographical distances are used as edge weights maximum link throughputs are used as edge weights Number of IMP hops are used as edge weights

4.1.2 Flooding Algorithm


Every incoming packet is sent out on every outgoing line except the one it arrived on Problem: Vast number of duplicated packets

Reducing Flooding Algorithms Duplicate Packets


Solution 1
Have a hop counter in the packet header IMPs decrement each arriving packets hop counter IMPs discard a packet with hop count=0 Ideally, the hop counter should be initialized to the length of the path from the source to the destination

Reducing Flooding Algorithms Duplicate Packets (contd)


Solution 2
Require the first IMP hop to put a sequence number in each packet it receives from its hosts Each IMP maintains a table listing the sequence numbers it has seen from each first-hop IMP. The IMP can then discard packets it has already seen.

Flooding: Possible Applications


Military Applications
Large number of IMPs is desirable If one IMP is taken out (by a bomb?) flooding will still get packets to their destinations

Distributed Databases
Simultaneous updates of multiple databases can be done with a single packet transmission

Wireless Networks
Inherently broadcasting/flooding

4.2 Adaptive Routing Algorithms


Problems with non-adaptive algorithms
If traffic levels in different parts of the subnet change dramatically and often, nonadaptive routing algorithms are unable to cope with these changes Lots of computer traffic is bursty, but nonadaptive routing algorithms are usually based on average traffic conditions

Adaptive routing algorithms can deal with these situations

Adaptive Routing Algorithms (contd)


Three Types:
Centralized Adaptive Routing
one central routing controller

Isolated Adaptive Routing


based on local information does not require exchange of information between routers

Distributed Adaptive Routing


routers periodically exchange information

4.2.1 Centralized Adaptive Routing


Routing table adapts to network traffic A routing control center is somewhere in the network Periodically, each IMP forwards link status information to the control center The center can, with Dijkstras shortest path algorithm, compute the best routes Best routes are dispatched to each IMP

Problem with Centralized Algorithms


Vulnerability
If the control center goes down, routing becomes nonadaptive

Scalability
The control center must handle a great deal of routing information, especially for larger networks

4.2.2 Isolated Adaptive Routing Algorithms


Routing decisions are made only on the basis of information available locally in each IMP Examples:
Hot Potato Backward Learning

Hot Potato Routing


When a packet arrives, the IMP tries to get rid of it as fast as it can by putting it on the output line that has the shortest queue Hot potato does not care where the output line leads Not very effective

Backward Learning Routing


Packet headers include destination and source addresses. They also include a hop counter Network nodes, initially ignorant of network topology, acquire knowledge of the network state as packets are handled

Backward Learning
Algorithm:
Routing is originally random A packet with a hop count of one is from a directly connected node; thus, neighboring nodes are identified with their connecting links A packet with a hop count of two is from a source two hops away, etc. As packets arrive, the IMP compares the hop count for a given source address with the minimum hop count already registered; if the new one is less, it is substituted for the previous one

4.2.3 Distributed Routing Algorithms


Each IMP periodically exchanges routing information (e.g., estimated time delay, queue length, etc.) with its neighbors Examples:
Distance Vector Routing
original ARPA net routing scheme, often called RIP (route information protocol)

Link State Routing


base for the current Internet routing algorithm

4.2.3.1 Distance Vectors


Known as Bellman-Ford or Ford-Fullkerson algorithm Each IMP, or router, maintains lists of best-known distances to all other known routers. These lists are called vectors. Each router is assumed to know the exact distance (in delay, hop count, etc.) to other routers directly connected to it. Periodically, vectors are exchanged between adjacent routers, and each router updates its vectors.

3
A

2
X

A -> X = min { (A -> B) + (B -> X), (A -> C) + (C -> X)}

Distance Vectors (contd)

Place Fig. 5-10 from Tanenbaum p. 356 here

Problem: Count-to-Infinity
With distance vector routing, good news travels fast, but bad news travels slowly When a router goes down, it can take a really long time before all the other routers become aware of it

In the following two examples, distance is measured in hops.

Count-to-Infinity
A 1 B 1 C 1 D 1 E Infinity Infinity infinity infinity Initially (A is down) A comes up 1 1 1 1 infinity infinity infinity 2 2 2 After 1 exchange

infinity infinity After 2 exchanges 3 3 infinity After 3 exchanges 4 After 4 exchanges

Good news travels fast.

Count-to-Infinity
A 1 B 1 1 C 2 1 D 3 1 E 4 Initially A goes down 3 3 5 5 7 2 4 4 6 6 3 3 5 5 7 4 4 4 6 6 After 1 exchange After 2 exchanges After 3 exchanges After 4 exchanges After 5 exchanges

etc to infinity; bad news travels slow.

4.2.3.2 Link State Routing


Each router measures the distance (in delay, hop count, etc.) between itself and its adjacent routers The router builds a packet containing all these distances. The packet also contains a sequence number and an age field. Each router distributes these packets using flooding

Link State Routing (contd)


To control flooding, the sequence numbers are used by routers to discard flood packets they have already seen from a given router The age field in the packet is an expiration date. It specifies how long the information in the packet is good for. Once a router receives all the link state packets from the network, it can reconstruct the complete topology and compute a shortest path between itself and any other node using Dijsktras algorithm.

4.3 Hierarchical Routing


All routing algorithms have difficulties as the network becomes large For large networks, the routing tables grow very quickly, and so does the number of flood packets How can this be reduced?
Hierarchical routing

Hierarchical Routing (contd)


Segment the network into regions Routers in a single region know all the details about other routers in that region, but none of the details about routers in other regions Analogy: Telephone area codes

Hierarchical Routing (contd)

Insert Fig. 5-17 from p. 366 here

4.4 RIP and OSPF


RIP
Route Information Protocol One of the routing algorithms used by the Internet Based on distance vector routing Did not scale well, and it suffered the countto-infinity problem RIP is slowly being phased out

OSPF
Open Shortest Path First Routing algorithm now used in the Internet OSPF uses the Link State Routing algorithm with modifications to support: Multiple distance metrics (geographical distance, delay, throughput) Support for real-time traffic Hierarchical routing Security

OSPF (contd)
OSPF divides the network into several hierarchies:
Autonomous Systems (ASs)
groups of subnets

Areas
Groups of routers within an AS

Backbone Areas
Groups of routers that connect other areas together

OSPF (contd)
Autonomous System
Backbone Area Area Area Backbone Area

Area

Autonomous System

Area

Area

OSPF (contd)
Routers are distinguished by the functions they perform
Internal routers
Only route packets within one area

Area border routers


Connect to areas together

Backbone routers
Reside only in the backbone area

AS boundary routers
Routers that connect to a router outside the AS

OSPF: Modified Link State Routing


Recall: In link state routing, routers flood their routing information to all other routers in the network In OSPF, routers only send their information to adjacent routers, not to all routers. Adjacent does NOT mean nearest-neighbor in OSPF One router in each area is marked as the designated router Designated routers are considered adjacent to all other routers in the area OSPF combines link state routing with centralized adaptive routing

OSPF: Adjacency
Designated Router
To backbone area

F B D

A E C Example: C is adjacent to B but not to A or E B is adjacent to all routers in the area

Area

4.5 Recent Developments: IPv6


IPv4 (the standard IP protocol) is limited Most importantly, IP is running out of addresses. 32 bits is not enough. Real-time traffic and mobile users are also becoming more common

IP version 6 (Also called IPng, or IP next generation)

IPv6: The Changes


Large address space:
128-bit addresses (16 bytes) Allows up to
340,282,366,920,938,463,463,374,607,431,768,211,456

unique addresses

Fixed length headers


Improves the speed of packet processing in routers

IPv6: The Changes (contd)


Support for flows
Flows help support real-time service in the Internet A flow is a number in the IPv6 header that can be used by routers to see which packets belong to the same stream Guarantees can then be assigned to certain flows Example:
Packets from flow 10 should receive rapid delivery Packets from flow 12 should receive reliable delivery

Вам также может понравиться