computer networks module iii

188
COMPUTER NETWORKS Ajit K Nayak, Ph.D. Department of Computer Science & Information Technology, ITER, SOA University. Lecture Notes Module III

Upload: ajit-nayak

Post on 22-Jan-2018

119 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Computer Networks Module III

COMPUTER NETWORKS

Ajit K Nayak, Ph.D.

Department of Computer Science & Information Technology,

ITER, SOA University.

Lecture Notes

Module III

Page 2: Computer Networks Module III

Computer Networking / Module III/ AKN / 2

Out Line of Module III

Network Layer, Network Layer Protocols

Transport Layer, Congestion control &

Quality of service

Application Layer protocols

Readings: “Data Communications and Networking” Third

Edition, Behrouz A Forcuzan, Chapter 19 - Chapter 23

Page 3: Computer Networks Module III

Computer Networking / Module III/ AKN / 3

Network Layer

Lecture I

• Host-to-Host Delivery• Addressing

• Routing

•Network Layer Protocols• IPV4

• ARP

• ICMP

Page 4: Computer Networks Module III

Computer Networking / Module III/ AKN / 4

Network Layer

Protocol used is IP for Network Layer

Responsibility of this layer to deliver the

datagram to the correct destination host. i.e. host-to-

host delivery

Page 5: Computer Networks Module III

Computer Networking / Module III/ AKN / 5

Classful IP Addresses Each host on a TCP/IP internet is assigned a unique

32-bit unicast Internet address that is used in all communication with that host.

Each unicast IP address is a pair(netid, hostid), where netid identifies a network and hostid identifies a host on that network

The total address space is 232=4,294,967,296. But all addresses are not usable

It is represented in dotted decimal notation

128.11.3.31

1000000 00001011 00000011 00011111

Page 6: Computer Networks Module III

Computer Networking / Module III/ AKN / 6

Type of communication

Unicast: one-to-one communication. i.e. One source sends to exactly one destination host

Multicast: one-to-a group. i.e. one sources sends to a predefined group of destination hosts simultaneously

Broadcast: one-to-all. i.e. one source sends to all other hosts available in that network. Broadcast in Internet is not allowed.

Others: anycast, geocast, etc. read yourself!

Page 7: Computer Networks Module III

Computer Networking / Module III/ AKN / 7

Classes of IP addresses

Class A 0.0.0.0 – 127.255.255.255

Class B 128.0.0.0 – 191.255.255.255

Class C 192.0.0.0 – 223.255.255.255

Class D 224.0.0.0 – 239.255.255.255

Class E 240.0.0.0 – 255.255.255.255

0 netid hostid

1 0 netid hostid

1 1 0 netid hostid

1 1 1 0 multicast address

1 1 1 1 reserved for future use

Page 8: Computer Networks Module III

Computer Networking / Module III/ AKN / 8

IP Addresses Class A

First octet defines the netid and first bit is fixed

Max. no of network possible: 27-2=126

All zero and all one values can not be used

24 bits are used for hostid

Max no of hosts 224-2=16,777,214 per network can be connected to a class A network

Class B First two octet define the netid and two left bits are

fixed : 214-2=16,382 networks and

216-2=65,534 hosts/network

Page 9: Computer Networks Module III

Computer Networking / Module III/ AKN / 9

IP Addresses Class C: First three octet defines netid and three bits

fixed

221-2=2,097,151 networks

28-2=254 hosts/network

Class D: No net and host ids

First four bits are fixed, remaining 24 bits define multicastaddresses?

Class E: No use

Page 10: Computer Networks Module III

Computer Networking / Module III/ AKN / 10

Special Addresses

Network Addresses

Addresses having all zero hostids are used to identify a network and is not assigned to any host

Specific All 0s

. . .

123.0.0.0

123.50.16.90 123.65.7.34 123.90.123.4

Class A

Page 11: Computer Networks Module III

Computer Networking / Module III/ AKN / 11

Network Address

Find Network addresses of the following IP addresses

24.32.3.29

190.234.211.21

200.23.31.6

Page 12: Computer Networks Module III

Computer Networking / Module III/ AKN / 12

Special Addresses contd.

Direct Broadcast Addresses

Used by a router to broadcast a message to all hosts of a network

It can only be used as a destination address by specifying hostid as all 1s

Specific All 1s

. . .

221.45.71.0

221.45.71.20 221.45.71.64 221.45.71.99

Class C network

R

221.45.71.255

Page 13: Computer Networks Module III

Computer Networking / Module III/ AKN / 13

Special Addresses contd. Limited Broadcast Addresses

Used by a host to send a message to every other host in that network

It can only be used as a destination address by specifying netid and hostid as all 1s

Router blocks the packet and discards it.

All 1s All 1s

. . .

221.45.71.0

221.45.71.20 221.45.71.64 221.45.71.99

Class C network

R

Blocked here

Page 14: Computer Networks Module III

Computer Networking / Module III/ AKN / 14

Special Addresses contd. This Host Addresses

Used by a DHCP client at bootstrap as a source address to get a valid IP address from the DHCP server

It is specified by all 0s. The destination is a limited broadcast address

It is always a Class A address regardless of the network

All 0s All 0s

. . .

221.45.71.0

?.?.?.? 221.45.71.64 221.45.71.99

Class C network

B

Bootstrap server

221.45.71.1

Page 15: Computer Networks Module III

Computer Networking / Module III/ AKN / 15

Special Addresses contd.

Loop Back Addresses

Used by a host to communicate with itself without a special network interface

This is the address with first byte as 127 and the packet never goes out of the machine

127 AnyHostP1 P2

127.0.0.1

Page 16: Computer Networks Module III

Computer Networking / Module III/ AKN / 16

Private Network Addresses These IPs should not be used in internet but one

can use for hosts that do not require direct access to the Internet

These addresses are filtered by Internet routers and therefore do not have to be globally unique

10.0.0.0 – 10.255.255.255

172.16.0.0 – 172.31.255.255

192.168.0.0 – 192.168.255.255

Automatic Private IP Addressing Used by windows machine, if there is no DHCP available

169.254.0.0 – 169.254.255.255

Rfcs: 1466, 1918, 1597, 3927 etc.

Page 17: Computer Networks Module III

Computer Networking / Module III/ AKN / 17

Masking To reach at a host we have two level of hierarchy

1. Reach at destination network 2. Reach at host

Masking is a process that extracts the address of physical network from an IP address

Mask is an IP having netid all ones and hostid all zeros

141.14.2.21 255.255.0.0 141.14.0.0

A bit wise and operation is performed

10001101 00001110 00000010 00010101

11111111 11111111 00000000 00000000

141 14 0 0

Mask

Page 18: Computer Networks Module III

Computer Networking / Module III/ AKN / 18

Problems with classful There are three main problems with “classful” addressing,

1. Lack of Internal Address Flexibility: Big organizations are

assigned large, “monolithic” blocks of addresses that don't

match well the structure of their underlying internal networks.

2. Inefficient Use of Address Space: The existence of only three

block sizes (classes A, B and C) leads to waste of limited IP

address space.

3. Proliferation of Router Table Entries: As the Internet grows,

more and more entries are required for routers to handle the

routing of IP datagrams, which causes performance problems

for routers. Attempting to reduce inefficient address space

allocation leads to even more router table entries.

Page 19: Computer Networks Module III

Computer Networking / Module III/ AKN / 19

Subnetting This technique helps to divide one physical network

into some smaller subnets (i.e.to create hierarchies)

Advantage: Increasing popularity of LAN may exhaust the netids

When many hosts connected to a single network the messages are overcrowded due to the broadcast nature of LANs

The scheme allows multiple physical networks to share a same prefix (1980s)

A second extension is also available to divide suffix and prefix at an arbitrary point called classless addressing and supernetting (1990s)

Page 20: Computer Networks Module III

Computer Networking / Module III/ AKN / 20

Subnetting an Example

141.14.0.0

. . .

141.14.0.0

.2.20 .7.96 .22.90

R

141.14.0.0

141.14.0.0

R.2

.7

.22

Without subnet

With subnet

.2.20

.7.96

.22.90

141.14.2.0

141.14.22.0

141.14.7.0

Page 21: Computer Networks Module III

Computer Networking / Module III/ AKN / 21

Subnetting Rest of the Internet still fills as if one

network. i.e packet destinated at 141.14.2.21 still reach at router R and it is aware of three subnets.

Last two octets define two things1. subnetid 2. hostid

Delivery of packets now involve three steps

1. Delivery to the network

2. Delivery to the subnet

3. Delivery to the host

Page 22: Computer Networks Module III

Computer Networking / Module III/ AKN / 22

Example 1

Q. Design 8 subnets from 211.77.20.0

Ans. Taking 3 bits for subnet in last byte, remaining 5 bits are

used for hostid

Page 23: Computer Networks Module III

Computer Networking / Module III/ AKN / 23

Example 1 contd.

According to classic IP routing rules, it was not possible to use the

subnets with all zero or all one values. i.e. subnet #0 and subnet #7

However, most modern machines have no troubles using uppermost or

lowermost subnets

Page 24: Computer Networks Module III

Computer Networking / Module III/ AKN / 24

Example 2 The network address is x.y.z.0, subnet mask is

255.255.255.248 then design the subnets

From mask it is clear that first five bits of last byte is used as subnetid and last three bits are used as hostids

i.e. 25=32 subnets and 23-2=6 hosts/subnets Subnet #0: x.y.z.0, x.y.z.1, . . ., x.y.z.6, x.y.z.7

Subnet #1: x.y.z.9, x.y.z.10, . . ., x.y.z.14, x.y.z.15

Subnet #2: x.y.z.16, x.y.z.17, . . ., x.y.z.22, x.y.z.23

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Subnet #29: x.y.z.232, x.y.z.233, . . ., x.y.z.238, x.y.z.239

Subnet #30: x.y.z.240, x.y.z.241, . . ., x.y.z.246, x.y.z.247

Subnet #31: x.y.z.248, x.y.z.249, . . ., x.y.z.254, x.y.z.255

First column is used as subnet id, last column is used as broadcast address.

Page 25: Computer Networks Module III

Computer Networking / Module III/ AKN / 25

IP addresses are used not only to

uniquely identify IP addresses

but also to facilitate the routing

of IP datagrams over networks

Page 26: Computer Networks Module III

Computer Networking / Module III/ AKN / 26

Problems with IP Addressing If a host computer moves from one network to another, its IP

address must change (manually)

Because routing uses the network portion of the IP address, the path taken by packets traveling to a host with multiple IP address depends on the address used.

Addressing Authorities

IANA: Internet Assigned Number Authority upto 1998

ICANN: Internet Corporation for Assigned Names and Numbers

R A B

Network 1

Network 2

I2I2 I3

I5I4

If link I3 fails than A cannot send to B

Page 27: Computer Networks Module III

Computer Networking / Module III/ AKN / 27

Dynamic Address configuration Each computer that is connected to Internet must have

following information Its IP address

Subnet mask

Router/gateway‟s IP address

Name server‟s IP address

These information are maintained in operating system and stored in disk

These information may be acquired by assigning static values or can also be obtained dynamically when needed

DHCP is designed to assign these information dynamically (on demand)

It is a client/server program, when client sends a request to server, server selects an IP address from the pool of unused IP address for a negotiable period of time (lease time)

Page 28: Computer Networks Module III

Computer Networking / Module III/ AKN / 28

Dynamic Host Configuration Protocol

TRANSITION STATES

All the DHCP servers replies with a DHCPOFFER message, which contains IP address, lease time etc.

client chooses on of the offers. Client now sends a DHCPREQUEST message

Requesting state

Remains in this state till it gets the DHCPACK, which creates a binding of physical and logical address

Initializing state Client broadcasts a

DHCPDISCOVER message

Selecting state

Page 29: Computer Networks Module III

Computer Networking / Module III/ AKN / 29

DHCP contd. Bound state

After using 50% of the time, client requests for renewal by sending another DHCPREQUEST, or client can cancel the lease and go back to the initializing state

Renewing state

If it receives the DHCPACK then the timer is reset or client goes again for rebinding. If not received till 87.5% of lease time then goes to rebinding state

Rebinding state

It remains in this state till it receives a DHCPNAK or lease expires, client goes to initializing state for a fresh process or goes to bound state if DHCPACK is received

Page 30: Computer Networks Module III

Computer Networking / Module III/ AKN / 30

Network Address Translation Home users and small business can be connected to Internet

via an ADSL or cable modem and every body needs one or more IP addresses

Due to shortage of IP addresses, the demand may be full filled by using the private network address through Network address translation method (NAT)

NAT enables a user to have large set of addresses (private) internally and one or a small set of addresses externally (global)

Address translation

Page 31: Computer Networks Module III

Computer Networking / Module III/ AKN / 31

NAT contd. Address translation

All out going packets go through the NAT router, which replaces destination address in the packet with global NAT address.

Similarly all incoming packets also pass through the NAT router, which replaces the destination address with appropriate private address using Translation table

Private Address

Private Port

ExternalAddress

External Port

TransportProtocol

172.18.3.1 1400 25.8.3.2 80 TCP

172.18.3.2 1401 25.8.3.2 80 TCP

... ... ... ... ...

Page 32: Computer Networks Module III

Computer Networking / Module III/ AKN / 32

Routing techniques Usually routing uses an Internet routing table on each

machine that stores information about possible destinations and how to reach them

Next Hop Routing

network

10.0.0.0

network

20.0.0.0

network

30.0.0.0

network

40.0.0.0

Q R

SDest Next hop

10.0.0.0 20.0.0.5

20.0.0.0 Direct

30.0.0.0 Direct

40.0.0.0 30.0.0.7

10.0.0.5

20.0.0.5

20.0.0.6

30.0.0.6

30.0.0.7

40.0.0.7

Page 33: Computer Networks Module III

Computer Networking / Module III/ AKN / 33

Network-Specific Routing

Instead of one entry for each destination host, we maintain one entry for total network

Page 34: Computer Networks Module III

Computer Networking / Module III/ AKN / 34

Host-Specific Routing Host-specific routes

Although all routing is based on networks and not on specific hosts, most software allows per-host routes as a special case.

This is helpful for administration purposes like testing, controlling access and debugging etc.

Net1

Net2 Net3

R

P

Q

A

B

Destination Next hop

B R

Net2 Q

Net3 R

Table for host A

Page 35: Computer Networks Module III

Computer Networking / Module III/ AKN / 35

Default Routing Default Routes

In this type of routing , it looks in the routing table for the destination network. If no route appears in the table, the routing routines send the datagram to a default router

It is useful when the network has a small set of local addresses and only one connection to the rest of internet

Rest of

Internet

network

10.0.0.0

network

20.0.0.0Q

SDestination Next hop

20.0.0.0 Q

Default S

• Routing table

for a host on

network 10.0.0.0

Page 36: Computer Networks Module III

Computer Networking / Module III/ AKN / 36

Static versus Dynamic Routing Tables Routing tables may be constructed statically or

dynamically. The success of routing depends on the consistency of routing table information

Static Routing table

Information entered manually, can be used for small intranet that does not change very often. It is not a good choice in Internet where information changes very often

Dynamic Routing table

Updated periodically using the dynamic routing protocols like RIP, OSPF, or BGP etc.

Dynamic routing is preferred over static routing as the updation of routing table is done dynamically thus providing a consistent routing mechanism.

Page 37: Computer Networks Module III

Computer Networking / Module III/ AKN / 37

Hierarchical Routing It is not possible to keep information about each host and or

each network in the routing table of each Internet router

To solve this problem we maintain hierarchical routing. According to this technique the we maintain partial information in routers

e.g. if the block assigned to one ISP is a.b.c.d/n and it may create many subnets of e.f.g.h/m for each of its customers, the rest of the Internet does not have to be aware of this division. i.e. all customer of that ISP are defined as a.b.c.d/n to the rest of Internet

There is only one entry needed for this ISP

The router inside ISP recognizes the sub-blocks and routes the packets to the destination

To reduce the size of table further the hierarchical routing may be included. i.e. The routers of ISPs outside Europe will have only one entry for packets to Europe in their routing tables.

Page 38: Computer Networks Module III

Computer Networking / Module III/ AKN / 38

Internet Protocol (IPV4:RFC-791) Connection less delivery system

Internet service consists of an unreliable, best-effort, connection less packet delivery system.

Unreliable because delivery is not guaranteed.

i.e.The packet may be lost, duplicated, delayed or delivered out of order but the service will not detect such conditions, nor will it inform the sender or receiver.

A sequence of sent from one computer to another may travel over different paths, or some may be lost while others are delivered.

It is best-effort delivery because the internet software makes an earnest attempt to delivery packets

i.e. the internet does not discard packets always. Unreliability arises only when resources are exhausted or underlying networks fail.

Page 39: Computer Networks Module III

Computer Networking / Module III/ AKN / 39

Internet Protocol (contd.) The Internet protocol defines unreliable, connection less

delivery mechanism ( IP )

It defines the basic unit of data transfer used throughout the internet by specifying the exact format of data

It performs routing function, choosing the path over which the data will be sent

It also includes a set of rules that embody the idea of unreliable packet delivery.

i.e. It tells how to process the packets, how and when error message should be generated, and the conditions under which the packets can be discarded.

Page 40: Computer Networks Module III

Computer Networking / Module III/ AKN / 40

Internet Protocol Datagram Format

Ver Total length

Fragment offsetIdentification

Source IP

Destination IP

IP Options if any

Data

. . .

Service TypeHLen

Flag

TTL Protocol Header checksum

Padding

0 4 8 16 19 24 31

Page 41: Computer Networks Module III

Computer Networking / Module III/ AKN / 41

IP Header Ver: version of IP (4 or 6)

HLen: total length of datagram header (20-60 bytes)

Type of Service: how the datagram should be handled by the router

Precedence: (3 bits) defines priorities in cases like congestion

TOS bits: low delay, high throughput, high reliability, less cost. A hint to router as a decision making factor for routing algorithms. Internet does not guarantee to provide any particular type of service

IETF redefined the meaning

If last three bits are zero than first three bits define precedence (backward compatibility)i.e. xxx000

Precedence D T R C

0 4 7

CODEPOINT unused

0 6 7

Page 42: Computer Networks Module III

Computer Networking / Module III/ AKN / 42

IP Header (contd.) The 64 code point values maps to an underlying

service definition and is divided into three groups

Pool Codepoint Assigned by

1 xxxxx0 Standards Organization(IETF)

2 xxxx11 Local or Experimental

3 xxxx01 Local or experimental for now

If the standards bodies exhaust all values in pool 1, they may also choose to assign values in pool 3

Total Length: defines total length of the datagram in bytes.

i.e. 216-1=65,535 bytes max. including header

Page 43: Computer Networks Module III

Computer Networking / Module III/ AKN / 43

IP Header (contd.) Fragmentation

Each datagram is encapsulated in a datalink frame before transmission.

It has to travel through different networks and the frame size differs for different networks and is defined by MTU of that network

Identification: IP software keeps a global counter and increments each time a new datagram created.

if the datagram is fragmented then the identification is copied to each fragment of same datagram

Flags: 3 bit field, D:do not fragment M: more fragment

U D M

Page 44: Computer Networks Module III

Computer Networking / Module III/ AKN / 44

IP Header (contd.) D=1: datagram must not be fragmented

D=0: datagram can be fragmented

M=1: It is not the last fragment

M=0: It is the last or only fragment

Fragmentation offset: It shows the relative position of the fragment, w.r.t. whole datagram

0 3999

0 1399

1400 2799

2800 3999

Offset measured in bytes

0/8 = 0

1400/8 = 175

2800/8 = 350

Page 45: Computer Networks Module III

Computer Networking / Module III/ AKN / 45

IP Header (contd.) Time to Live:It specifies how long in seconds, the

datagram is allowed to remain in the internet system

When a datagram arrives at a router, it records the time and before sending forward it decrements the time to live field.

When it becomes zero, the datagram is discarded and an error message is sent to the source

But to estimate exact time is difficult because routers do not usually know the transit time for physical networks.

Thus in practice the time to live acts as a hop limitrather than an estimate of delay. Each router only decrements the value by one till it becomes zero.

Page 46: Computer Networks Module III

Computer Networking / Module III/ AKN / 46

IP Header (contd.) Protocol: It defines the higher level protocol

that uses the IP layer service ICMP- 1, IGMP-2, TCP-6, UDP-17 etc.

Header Checksum: Ensures the integrity of header values Divide the packet in to k section of 16 bits each

All sections are added using ones complement method

The final result is complemented to make checksum

Follow the same method at receiver. If the result is zero accept else discard the datagram

Page 47: Computer Networks Module III

Computer Networking / Module III/ AKN / 47

IP Header Options IP header is made of two parts: the fixed part and the

variable part. Fixed part is 20 byte long; the variable part comprises the option which can be a max. of 40 bytes.

These are included primarily for network testing and debugging

Format

Code: It contains copy(1), class(2), and number(5)

Copy = 1: options should be copied to all fragment

Copy = 0: options must be only copied to first fragment

Code(8) Length(8) Data (variable length)

Copy Class Number

Page 48: Computer Networks Module III

Computer Networking / Module III/ AKN / 48

Options field of IP Datagram Class

00 : used for datagram control, 01: reserved

10: Debugging and management, 11: reserved

Number

Defines the type of options

Length

It defines the total length of the option including the code field and the length field itself

Data

Contains the data that specific options require

Page 49: Computer Networks Module III

Computer Networking / Module III/ AKN / 49

Types of Options 0 : End of option, used if options do not end at end of header

1: no operation, used to align octets

7: Record Route, It is used to record the routers that handles the datagrams. It can list up to nine router addresses?

The source creates empty fields for the IP addresses in the data field of the option

Options

Data0

7-byte opt

8-byte opt

1

Code Length Pointer

First IP Address (empty)

Second IP Address (empty)

Third IP Address (empty)

Page 50: Computer Networks Module III

Computer Networking / Module III/ AKN / 50

Types of Options Whenever a router handles the datagram, it compares

the pointer and length field. If the pointer field is greater than length field, the list is full.

Else router inserts its IP address at the position specified by pointer and increments the pointer by four.

This option requires that two machines must cooperate. i.e. source must enable record route and destination must agree to process the resultant list.

9: Strict source route, used by the source to predetermine a route for the datagram as it travels through internet i.e. a source may choose a safer route to the destination

Page 51: Computer Networks Module III

Computer Networking / Module III/ AKN / 51

Types of Options If a datagram specifies a strict source route, all of the

routers defined in the option must be visited in order by the datagram.

If a datagram reaches at a router not in the list then it is discarded and error message is sent to the source.

If a datagram reaches at the destination and some entries were not visited, it will also be discarded and error message is issued.

i.e. The path between two successive addresses in the list must consists of a single physical network

It is only useful when the network topology is known

Page 52: Computer Networks Module III

Computer Networking / Module III/ AKN / 52

Types of Options 3: Loose source route, It is similar to strict source but allows

multiple network hops between successive address in the list

Both source route options requires routers along the path to overwrite the list with their local network address.

4: Timestamp, is used to record the time of datagram processing by the router.

Code Length Pointer

First IP Address

First Timestamp

. . .

OFlow Flags

Page 53: Computer Networks Module III

Computer Networking / Module III/ AKN / 53

Types of Options Length and pointer fields are used to specify the

length of the space reserved for the option and the location of the next unused slot.

Oflow(4) contains an integer count of routers that couldnot supply timestamp because the option was too small

Flag(4), controls the exact format of the option and tells how routers should supply timestamps. 0: Record timestamps only, omit IP addresses

1: Precede each timestamp by an IP address

3: IP addresses are specified by sender; a router only records a timestamp if the next IP address in the list matches the router‟s IP address

Page 54: Computer Networks Module III

Computer Networking / Module III/ AKN / 54

Routing IP Datagrams Routing is the process of choosing a path over which

to send packets, and router refers to a computer making the choice

The goal of IP is to provide a virtual network that encompasses multiple physical network and offers a connection less datagram delivery service

Routing is divided into two forms

1. Direct delivery: Transmission of a datagram from one computer across a single physical network directly to another

2. Indirect delivery: Transmission of datagram to a destination not attached directly to the senders network, thus forcing the sender to pass the datagram to a router for delivery

Page 55: Computer Networks Module III

Computer Networking / Module III/ AKN / 55

Datagram delivery over a single Network

In this case the final destination of the datagram is a host connected to the same physical network

R

• The sender extracts the network address of destination IP and

compares it to the network portion of its own IP .

• If a match is found then the delivery is direct and it does not

involve routers

• Now the destination IP address is used to find its physical

address for actual datalink layer delivery?

• Extraction of network address

takes a few machine instructions

making the process extremely

efficient

Page 56: Computer Networks Module III

Computer Networking / Module III/ AKN / 56

Indirect Delivery It is more difficult because the sender must identify a

router to which the datagram can be sent

R

R

• The datagram goes from router to

router until it reaches the destination

network• At the destination network it

performs direct delivery to reach

at the host

• How can a host know which router to use for a given

destination?

• How can a router know where to send datagrams?

Page 57: Computer Networks Module III

Computer Networking / Module III/ AKN / 57

Mapping Internet Address to Physical Address

Delivery of a packet requires two levels of addressing.

Hosts and routers are recognized at the network level by their logical addresses, which is universal and implemented in software

But at physical level devices are recognized by their physical addresses

Therefore, the packet to be sent from A to B should be mapped to the physical address of B

Address mapping must be performed at each step along a path from original source to ultimate destination

i.e 1. Last hop addressing 2. Intermediate addressing

Page 58: Computer Networks Module III

Computer Networking / Module III/ AKN / 58

Mapping Internet Address Physical Address

Last hop addressing Packet‟s internet address is mapped to the final

destinations physical address

Intermediate addressing At any point along the path packet is mapped to

intermediate routers physical address (as destination)

Address resolution problem The problem of mapping logical to physical address is

called the ‘address resolution problem’.

There are two technologies followed by TCP/IP to resolve the problem.

1. Resolution through direct mapping

2. Resolution through Dynamic binding

Page 59: Computer Networks Module III

Computer Networking / Module III/ AKN / 59

Mapping Internet Address Physical Address Resolution through Direct Mapping

In proNET token ring network, the administrator chooses small integers for physical addresses while installing an interface.

Now to have a efficient address resolution one can find a function PA = f (IA) to calculate the numbers.

i.e. if f is simple then the mapping will be simple

Another way is to keep a table containing address pairs (logical, physical) and a hash function may be used to search that table

Another advantage in this method is, if one interface of a computer is changed then also the same physical address can be used for the new interface

Also new computers can be added to the network without changing the existing assignments.

Page 60: Computer Networks Module III

Computer Networking / Module III/ AKN / 60

Mapping Internet Address Physical Address

Resolution through dynamic binding In Ethernet technology the 48 bit physical address is

assigned when manufactured

Thus the physical address of a computer changes each time an interface is changed.

Because the physical address is 48 bit long and not assigned by the user thus it is impossible to devise a function for mapping as in previous case

To avoid maintaining a mapping table (not possible !) the designers developed a protocol to bind addresses dynamically known as „Address Resolution Protocol‟

ARP provides a mechanism that is both reasonably efficient and easy to maintain

Page 61: Computer Networks Module III

Computer Networking / Module III/ AKN / 61

Resolution through dynamic Binding Idea

Sender broadcasts a special packet that asks the destination about its physical address

Destination recognizes the packet and sends a reply containing its physical address

Now the sender uses physical address to send packets directly to destination

A B C D

A B C D

A B C D

Page 62: Computer Networks Module III

Computer Networking / Module III/ AKN / 62

ARP Packet Format (RFC-826)

H/W Type: 16 bit field defines type of LAN e.g. Ethernet=1

Protocol Type: 16 bit field defining IP version e.g. IPV4=0080016

Hlen: 8 bit, length of hardware address e.g. Ethernet = 6

Plen : 16 bit, length of logical address

Operation : 8 bit, request=1, reply 2

Hardware Type Protocol Type

OperationH/W length Protocol length

Sender Hardware Address

Sender Protocol Address

Target Hardware Address

Target Protocol Address

Page 63: Computer Networks Module III

Computer Networking / Module III/ AKN / 63

Address Resolution Protocol

Encapsulation ARP packet is encapsulated directly in to a

datalink frame

Refinements If the target machine is down or too busy to

accept the request? i.e sender may not receive a reply (1) or it is delayed(2)

Retransmit the request for (1) or it restores the original outgoing packet till it resolves the address

SFD Dest Add Source Add Type Data CRC

ARP Packet

Page 64: Computer Networks Module III

Computer Networking / Module III/ AKN / 64

ARP Implementation ARP Cache

After receiving an ARP reply, it saves the IP address and corresponding hardware address in its cache for successive lookups

But problem occurs if receiver crashes in between and source gets no information but keep on sending

To resolve above problem a timer is used, when it expires the information in the cache is erased and normal procedure starts again

Another refinement possible is, senders IP-Physical address binding can also be updated in receivers cache before processing the ARP request

Page 65: Computer Networks Module III

Computer Networking / Module III/ AKN / 65

Four cases using ARP

Page 66: Computer Networks Module III

Computer Networking / Module III/ AKN / 66

Limitations with IP A datagram travels from router to router till it reaches

one that can deliver directly to its final destination

If a router cannot route a datagram?

If the router detects an unusual condition that affects its ability to forward the datagram?

In an connectionless system, each router operates autonomously, i.e without coordination of sender. and

IP fails to deliver the datagram if The destination is temporarily or permanently disconnected

The TTL expires

The intermediate routers become so congested that they cannot process the incoming traffic

Page 67: Computer Networks Module III

Computer Networking / Module III/ AKN / 67

The Internet Control Message Protocol To allow routers in an internet to report errors or provide

information about unexpected circumstances, one mechanism is attached with IP is called

“The Internet Control Message Protocol”, ICMP

ICMP allows routers to send error or control messages to other router or hosts; It provides communication between the IP software on one machine and the IP software on another

i.e. The ultimate destination of an ICMP message is not an application program or user on destination but the IP software of that machine

ICMP is not restricted only to routers but is allowed to be used by any arbitrary machine to get some information.

ICMP messages travel across internet in the data portion of IP datagrams

Page 68: Computer Networks Module III

Computer Networking / Module III/ AKN / 68

Error Reporting / Error Correction When a datagram causes an error, ICMP can only report

the error condition back to the original source of the datagram.

The source must take some action to correct the error

It cannot be used to inform intermediate routers about the problem

An Example If a datagram follows a path R1, R2, . . ., Rk and Rk has the

incorrect information and mistakenly routes the datagram to Re

Now Re cannot use ICMP to report the error back to Rk but it can send a report back to the original source

And the original source has no control over the misbehaving router. In fact it is not possible for the source to know which router (Rk) causes the problem

Page 69: Computer Networks Module III

Computer Networking / Module III/ AKN / 69

ICMP Message Message Delivery

It requires two levels of encapsulationHeader ICMP Data

Header Datagram Data

Header Frame Data

– Even though ICMP messages are encapsulated and sent

using IP datagrams, it is not considered a higher level

protocol, but a required part of IP

– It is Because, it needs to travel across several physical

networks to reach their final destination

Page 70: Computer Networks Module III

Computer Networking / Module III/ AKN / 70

ICMP Message Format

Type : identifies the message type

Code : provides further information about the message type

Checksum : error detection

ICMP messages that report errors always include the header and first 64 bit data bits of the datagram causing the problem

Type (8 bit) Code (8 bit) Checksum (16 bit)

Rest of Header

Data . . .

(Variable size)

Page 71: Computer Networks Module III

Computer Networking / Module III/ AKN / 71

ICMP Message Format (contd.)

The total table is available in page 133 of D.E. Comer

Type Message

0 Echo Reply

3 Destination unreachable

4 Source Quench

5 Redirect (change route)

8 Echo Request

9 Router Advertisement

10 Router solicitation

11 Time Exceeded for a datagram

12 Parameter problem on a datagram

Ping: One of the most

frequently used

debugging tool that

invokes ICMP echo

request and echo reply

messages

- Any machine that

receives an echo request

formulates an echo reply

and return it to the

original sender

Page 72: Computer Networks Module III

Computer Networking / Module III/ AKN / 72

Echo Request and Reply Message

Optional Data is a variable length field that contains data to be returned to sender

Identifier and Sequence number are used by the sender to match replies to request.

The Type field specifies whether the message is a request (8) or reply (0)

Type(8 / 0) Code (0) Checksum

Data . . .

(optional)

Identifier Sequence no

Page 73: Computer Networks Module III

Computer Networking / Module III/ AKN / 73

Reports of Unreachable Destinations

When a router cannot forward or deliver an IP datagram, it sends a ‘destination unreachable’ message back to the original source

The code field contains an integer that further describes the problem

Code Meaning Cause 0: Network unreachable (h/w failure)

1: host unreachable (do)

2: Protocol unreachable (receiving protocol not running)

3: Port unreachable (receiving appl. Prg not running)

4: fragmentation required (D bit set) etc.

Type-3 Code (0-15) Checksum

Part of the received IP datagram including IP header +

first 8 byte of datagram data

Unused - all zeros

Page 74: Computer Networks Module III

Computer Networking / Module III/ AKN / 74

Congestion and Datagram flow control

IP doesn't have a flow control (rate of sending and receiving) mechanism, which may lead to congestion. i.e

The router eventually exhausts memory and discards additional datagrams arrived

‘Source quench’ message has been designed to add a kind flow control to IP.

When a datagram is discarded, it sends a source quench message to the sender, which helps in Reporting source that datagram is discarded

Make the source aware of congestion and to slow down

Type-4 Code -0 Checksum

IP header + first 8 byte of datagram data

Unused - all zeros

Page 75: Computer Networks Module III

Computer Networking / Module III/ AKN / 75

Route change requests

Routers are assumed to know correct routes; hosts begin with minimal routing information and learn new routes from routers

If a host sends a datagram to an incorrect router, then the router forwards the datagram in correct destination and sends a ‘redirect message’ to the host.

Now host updates its table accordingly

Code

0: redirection for the network

1 : redirection for the host

Type-5 Code (0-3) Checksum

IP header + first 8 byte of datagram data

Router Internet Address

Page 76: Computer Networks Module III

Computer Networking / Module III/ AKN / 76

Detecting Circular or long routes

This message is generated in two cases

Code 0: TTL exceeded

If there are errors in one or more routing table a datagram may travel in a loop. After some time when TTL becomes zero the datagram is discarded and a ‘Time exceeded’ message is sent to source

Code 1: Fragment reassembly time exceeded

If all fragments that belong to one datagram don‟t arrive at the destination within a time limit then the fragments are discarded and a Time exceeded message is sent to the source

Type-11 Code (0-1) Checksum

IP header + first 8 byte of datagram data

Unused

Page 77: Computer Networks Module III

Computer Networking / Module III/ AKN / 77

Reporting Other Problems

If a router or destination discovers an ambiguous or missing value in any field of the datagram header then it sends a ‘Parameter problem’ message back to source

Code 0: Error in header fields Pointer field points to the byte with problem

Code 1: Required part of option is missing Pointer field not used in this case

Type-12 Code (0-1) Checksum

IP header + first 8 byte of datagram data

Pointer Unused

Page 78: Computer Networks Module III

Computer Networking / Module III/ AKN / 78

Clock Synchronization and Transit Time Estimation

‘Time Stamp message’ is used by two machines to determine the round trip time needed for an IP datagram to travel between them

Each time the fields hold a no representing time measured in milliseconds from midnight in GMT

Calculation: Sending time = receive TS - Originate TS

Receiving time = datagram return time - Trnsmit TS

Round trip time = sending time + receiving time

Type(13-14) Code -0 Checksum

Source: Originate time stamp

Identifier Sequence number

Destination: Receive time stamp

Destination: Transmit time stamp (departure)

Page 79: Computer Networks Module III

Computer Networking / Module III/ AKN / 79

Obtaining a subnet mask

‘Address mask request/reply’ message are used by a host to obtain its mask from a router

Type(17-18) Code -0 Checksum

Address Mask

Identifier Sequence number

Router DiscoveryType(9) Code -0 Checksum

Router Address 1

Nun addr Life time

Preference level 1

Router Address 2

Addr size

Preference level 2 . . .

Page 80: Computer Networks Module III

Computer Networking / Module III/ AKN / 80

Router Solicitation/Advertisement

ICMP supports a router discovery scheme that allows hosts to discover router address.

A host can broadcast a ‘router solicitation’ message. The routers that receive the message broad cast their routing information using „router advertisement’ message

ICMP router discovery scheme helps in two ways

1. Instead of providing a statically configured router address via a boot strap protocol, the scheme allows a host to obtain information from router itself

2. The mechanism uses a soft state technique with timers to prevent hosts from retaining a route after a router crashes Routers advertise their information periodically, and a host discards a

route if the timer for a route expires (30min, 10min)

Type(10) Code -0 Checksum

Identifier Sequence number

Page 81: Computer Networks Module III

Computer Networking / Module III/ AKN / 81

Network Layer Protocols

Lecture II

• IPV6

• ICMPR6

• Unicast Routing protocols

• RIP

• OSPF

Page 82: Computer Networks Module III

Computer Networking / Module III/ AKN / 82

IPv6: Need for an alternative

IPv4 has two level address structure (?) andcategorized into 5 classes. The use of address spaceis inefficient

The internet must accommodate realtime audio andvideo transmission, which requires min delay andreservation of resources

The Internet must accommodate encryption andauthentication of data for some application

Not only the computers but various devicesincluding house hold devices, hand held devices,telephones etc. needs IP address

Page 83: Computer Networks Module III

Computer Networking / Module III/ AKN / 83

Characteristics of IPv6 Larger Address Space: 128 bit long

Huge increase in address space

Better header format options are separated from base header

New options To add new functionalities

Allowance for extension To support new technologies

Support for resource allocation To support traffic such as real-time audio and video

Support for more security Encryption and authentication mechanism

RFCs 1365, 1550, 1678, . . .

Page 84: Computer Networks Module III

Computer Networking / Module III/ AKN / 84

IPv6 address

• 128 bits are divided into eight sections of hexadecimal nos, each 2

byte long sections separated by colons

• The address may be abbreviated, i.e the leading zeros can be

omitted (not trailing zeros)

• consecutive sections consisting of zeros

can be replaced with double semicolons

• if there are two runs of zero section than

only one of them can be abbreviated

Page 85: Computer Networks Module III

Computer Networking / Module III/ AKN / 85

Unicast Addresses Defines two types of unicast addresses

Geographically based unicast address (left for future definition)

Provider based unicast address (discussed below)

Type identifier: 3 bit field defines the address as a provider-based address

Page 86: Computer Networks Module III

Computer Networking / Module III/ AKN / 86

Unicast Addresses contd.

Registry identifier: 5bit field indicates the agency that has registered the address.currently three registry has been defined. INTERNIC: center for North America

RIPNIC: center for European registration

APNIC: for Asian and Pacific countries

Provider indentifier: variable-length field identifies the provider for Internet access (like ISP). A 16 bit length is recommended for this field

Subscriber identifier: a 24 bit is assigned to an organization subscribing to the Internet via provider

Subnet identifier: a 32 bit is assigned to define a subnet under the territory of a subscriber

Node identifier: a 48 bit is assigned for the identity of the node connected to subnet

Page 87: Computer Networks Module III

Computer Networking / Module III/ AKN / 87

Multicast addresses First 8 bits all 1s

Flag: 4bit field that defines the group address as either permanent or transient

Scope: 4 bit field defines scope of the group address

Group ID: 112 bits identifies group

Anycast addresses

A packet destinated for anycast address is delivered to only one member of the anycast group. i.e. member having shortest route

No block is assigned to for this anycast address

Page 88: Computer Networks Module III

Computer Networking / Module III/ AKN / 88

Reserved addresses Start with eight zeros

Unspecified address is used when a host does not know its own address

Loopback address is used by a host to test itself

Compatible address is used during the transition from IPv4 to IPv6. i.e. when passing from IPv6 to IPv6 via IPv4 network

Mapped address is also used during transition when sending from Ipv6 to IPv4 computer

Page 89: Computer Networks Module III

Computer Networking / Module III/ AKN / 89

Local addresses Used when an organization wants to use IPv6

without being connected to Internet

Nobody outside the organization can send a message to the nodes using these addresses

A link local address is used in an isolated subnet

A site local address is used in an isolated site with several subnets

Page 90: Computer Networks Module III

Computer Networking / Module III/ AKN / 90

Format of an IPv6 datagram

• Each packet is composed of a mandatory base header (40 bytes) followed by a payload.

• Payload consists of two parts (65535 bytes)

• Optional

extension header

• Data from an upper layer

Page 91: Computer Networks Module III

Computer Networking / Module III/ AKN / 91

Base Header Version(4): version of IP

Priority(4): priority of the packet w.r.t. congestion

Flow level(3byte): special handling for a particular flow of data

Payload length(2 byte): total length of datagram excluding base header

Next header(8): either one of the optional extension headers used by IP or the header for an upper layer protocol like UDP, TCP

Hop Limit(8): same as TTL

Source Address(16byte): IP of source

Source Address(16byte): IP of destination

Page 92: Computer Networks Module III

Computer Networking / Module III/ AKN / 92

Comparison between IPv4 and IPv6 packet headers

Page 93: Computer Networks Module III

Computer Networking / Module III/ AKN / 93

Extension headerThe base header can be followed by six extension headers

Hop-by-hop Option Is used when the source needs to pass information to all

routers visited by the datagram. Three options are defined

Pad1: 1 byte, designed for alignment purposes

PadN: used when 2 or more bytes needed for alignment

Jumbo payload: is used to define a payload longer than 65535 bytes

Fragmentation Only original source can fragment after using a path MTU

discovery to get the smallest MTU supported by any network on the path

If it will not use the technique then it must fragment a datagram to a size <= 576 bytes

Page 94: Computer Networks Module III

Computer Networking / Module III/ AKN / 94

Extension header contd. Authentication

It validates sender, and ensures integrity of data

Encrypted Security Payload

It provides confidentiality and guards against eavesdropping

Source Routing

Uses the concept of strict/loose source routing

Destination Option

Is used when the source needs to pass information to the destination only. Intermediate routers are not permitted access too this information

Page 95: Computer Networks Module III

Computer Networking / Module III/ AKN / 95

Comparison between IPv4 options and IPv6 extension headers

Page 96: Computer Networks Module III

Computer Networking / Module III/ AKN / 96

Transition from IPv4 to IPv6Because of huge systems using IPV4 that‟s

why three strategies were proposed for smooth transition

Dual stack A station should run both IPv4 and

IPv6 simultaneously until all the Internet uses IPv6

If DNS returns IPV4 address then source sends IPV4 packet else IPV6 packet

Tunneling When two computers using IPV6 want

to communicate with each other and the the packet has to pass through a region that uses IPV4

Therefore IPV6 packet is encapsulated in an IPV4 datagram when it enters that IPv4 region

Page 97: Computer Networks Module III

Computer Networking / Module III/ AKN / 97

Transition from IPv4 to IPv6 Header Translation

It is necessary when the majority of the Internet has moved to IPv6

i.e. If sender uses IPv6 but receiver uses IPv4

Header must be completely translated

It uses mapped address of IPv6

Page 98: Computer Networks Module III

Computer Networking / Module III/ AKN / 98

ICMPv6

Comparison of query messages in ICMPv4 and ICMPv6

Comparison of error-reporting messages in ICMPv4 and ICMPv6

Page 99: Computer Networks Module III

Computer Networking / Module III/ AKN / 99

Unicast Routing Protocols A routing protocol allows routers share their knowledge

(routing information) about the network with other routers.

They maintain a table to keep routing information. This table gets updated periodically after receiving information from neighbouring routers

Routers use routing table to decide about the best route based on a cost metric

Cost metric Hop count: cost of passing through any network is same. i.e. passing

through one network costs 1 hop

Max throughput: throughput is more in passing through an fiber than in radio link

Min delay: delay is less in fiber than satellite link

Reliability: some networks may be more reliable than others, it is decided based on a policy.

Various routing protocols available are RIP, OSPF etc.

Page 100: Computer Networks Module III

Computer Networking / Module III/ AKN / 100

Routing Information Protocol It is based on Distance Vector routing, which uses Bellman-

Ford algorithm for calculating the routing table

Distance Vector Routing

In this scheme, each router periodically (30 s) shares (broadcasts) its own routing information with its neighbours

Every router keeps a routing table that has three columns in its simplest form for each entry about a network

• A, B,C, D are

(routers)

• To: destination

network

• Cost: hop count

• Next: next hop

Page 101: Computer Networks Module III

Computer Networking / Module III/ AKN / 101

RIP UpdatingReceive: a response RIP message1. Add one hop to the hop count for each advertised

destination.2. Repeat the following steps for each advertised

destination: 1. If (destination not in the routing table)

1. Add the advertised information to the table. 2. Else

1. If (next-hop field is the same) 1. Replace entry in the table with the advertised one.

2. Else 1. If (advertised hop count smaller than one in the

table) 1. Replace entry in the routing table.

3. Return.

Page 102: Computer Networks Module III

Computer Networking / Module III/ AKN / 102

Example of updating a routing table

Page 103: Computer Networks Module III

Computer Networking / Module III/ AKN / 103

Initial and Final routing tables in an example network

Page 104: Computer Networks Module III

Computer Networking / Module III/ AKN / 104

Problems with RIP: Count-to-infinity Count to infinite

Suppose there is a network as shown

Each router keeps the information about A initially as shown

Now A goes down or link between A and B Brakes

At the first packet exchange B will not receive any message from A

But C tells B that it has a path to A of length 2

B now updates its own information about A according updation algo and make it 3

1, - 2, B 3, C 4, D 5, E

A B C D E F

Initially

After 1 exchange

After 2 exchanges

After 3 exchanges

After 4 exchanges

After … exchanges

3, C 2, B 3, C 4, D 5, E

3, C 4, B 3, C 4, D 5, E

5, C 4, B 5, C 4, D 5, E

5, C 6, B 5, C 6, D 5, E

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

•The number of exchanges required depends

on the numerical value used for infinity.

•In RIP the value is kept 16, that’s why it

can’t be used in large systems

Page 105: Computer Networks Module III

Computer Networking / Module III/ AKN / 105

Open shortest path First (OSPF) It is based on link state routing that uses dijkstra‟s

algorithm

Link state routing In this scheme, each router shares the knowledge about its

own neighbours to all other routers using flooding

Each router maintains a database about its neighbours and sends it when there is a change or after a large period.

The idea is that all routers should have a complete topology of the network. From this topology the router can calculate the shortest path between itself and the destination network using dijkstra‟s graph algorithm

The topology is represented as a graph, where vertices are networks or routers and edges are links.

A cost is associated with each link

Page 106: Computer Networks Module III

Computer Networking / Module III/ AKN / 106

Link state Routing Learning about neighbours

When router is booted, it sends a hello packet on each point-to-point line

The router at the other end sends back a reply

Measuring Link cost

One echo packet is sent and its time is recorded, other side sends the packet back immediately and the time of receiving is recorded again

The test is conducted several times and the average RTT is calculated for better result

Building the Link state packets

Identity of sender, sequence #, age, a list of neighbours with their link costs

Page 107: Computer Networks Module III

Computer Networking / Module III/ AKN / 107

Link state Knowledge Whole topology can be compiled from the partial

knowledge of each node

Page 108: Computer Networks Module III

Computer Networking / Module III/ AKN / 108

Formation of shortest path tree The dijkstra‟s algorithm creates a single source shortest path tree

given a graph(topology), each node is assigned a cumulative cost from root to that node (called weight or total cost)

Page 109: Computer Networks Module III

Computer Networking / Module III/ AKN / 109

Transport Layer

Lecture III

• User Datagram Protocol

• Transmission Control protocol

• Congestion Control and Quality of

services

Page 110: Computer Networks Module III

Computer Networking / Module III/ AKN / 110

Transport Layer

Protocols used for Transport Layer are UDP or TCP

The responsibility of transport layer is to deliver the

message to the receiving process/Application. i.e.

process to process delivery

Page 111: Computer Networks Module III

Computer Networking / Module III/ AKN / 111

Review Internet layer provides a host-to-host packet delivery

The next problem is turn this service to process-to-process delivery

The Transport layer supports communication between the end application programs, thus called end-to-end protocol

The underlying networks upon which the transport protocol operates has certain limitations like, it may Drop messages

Reorder Messages

Deliver duplicate copies of messages

Limit messages to some finite size

Delivery messages after a long delay

Page 112: Computer Networks Module III

Computer Networking / Module III/ AKN / 112

Review The operating system supports multiprogramming

But specifying that a particular process on a particular machine is the ultimate destination for a datagram is misleading, because Processes are created and destroyed dynamically(pid),

senders seldom know enough to identify a process on another machine

Processes may be replaced without informing to the senders

We need to identify destinations from the functions they implement without knowing the process

Instead of thinking a process as the ultimate destination, we will imagine that the machine contains a set of abstract points called protocol ports (integer nos.)

Page 113: Computer Networks Module III

Computer Networking / Module III/ AKN / 113

Review Operating system provides two types of access to

ports

1. Synchronous access computation stops during a port access operation.

i.e. if a process attempts to extract data from a port, then the operating system temporarily blocks the process till data is passed to the process and then restarts it

2. Asynchronous access Ports are buffered, so that data arrives before a process is

ready to access will not be lost

To achieve buffering the protocol software places the packets that arrive for a particular protocol port in a (finite) queue

Each message must carry the destination port on source

Page 114: Computer Networks Module III

Computer Networking / Module III/ AKN / 114

Types of data deliveries

Page 115: Computer Networks Module III

Computer Networking / Module III/ AKN / 115

Port Addressing At transport layer, port number is used to deliver a message to

the correct process out of several processes running on destination host

Port numbers are 16 bit integers between 0-65535.

The client program defines itself with a port number, chosen randomly by transport layer called ephemeral port numbers

The server program uses well known port number.

i.e. client gets a new port number each time it runs, but the port number for server is fixed

IANA defines some ranges Well-know ports: 0-1023 are assigned and controlled by IANA for some

well-know server processes

Registered ports: 1024-49151 are not assigned or controlled by IANA, but can be used by processes

Dynamic ports: 49151-65535 are neither controlled nor registered, called ephemeral ports

Page 116: Computer Networks Module III

Computer Networking / Module III/ AKN / 116

Other features Socket Address

The IP address and port number pair defines the socket address

The client and server‟s socket addresses define client and server processes uniquely

A pair of socket address (client and server‟s) uniquely defines a connection.

Multiplexing and demultiplexing At the sender side, there may be several processes need to

send packets, but there is one transport layer protocol.

Therefore the protocol accepts messages from different processes differentiated by their port numbers and interleaves them

At the receiver side, the transport layer receives interleaved packets from network layer and passes to appropriate application after processing

Page 117: Computer Networks Module III

Computer Networking / Module III/ AKN / 117

Other features contd. Connection-less vs connection-oriented service

In a connection less service, packets are sent from one party to another, without establishing the connection

In case of connection oriented, a connection is established, data transferred, then connection is released

Reliable vs unreliable Reliability is achieved by providing error and flow

control at transport layer (data transmission)

It becomes a slower and more complex service

Where as unreliable services are faster and simple to implement (real-time application)

Page 118: Computer Networks Module III

Computer Networking / Module III/ AKN / 118

The User Datagram Protocol (UDP) It is the simplest possible transport protocol that

extends the host-to-host delivery into a process-to-process communication service.

It only adds a level of demultiplexing, s.t. multiple application process on each host are allowed to share the network.

Aside from this requirement, UDP adds no other functionality to the best effort service.

UDP provides an unreliable connection less delivery service.

It uses IP to carry messages, but adds the ability to distinguish among multiple destinations within a given host computer.

Page 119: Computer Networks Module III

Computer Networking / Module III/ AKN / 119

The UDP message format

Port nos may vary from 0-65535, and source port is optional. These are used to demultiplex datagrams

The Length field contains a count of datagram in octets. Minimum length is 8

Checksum is optional and zero is kept if not computed

The UDP checksum provides the only way to guarantee that data has arrived intact and should be used

UDP Source Port

Data . . .

UDP Destination Port

UDP message length UDP Checksum

Page 120: Computer Networks Module III

Computer Networking / Module III/ AKN / 120

Checksum Calculation UDP uses the same checksum algorithm as IP

But UDP covers more information than is present in UDP datagram

It prepends a pseudo-header to the UDP datagram

Appends an octets of zeros to pad the datagram to an exact multiple of 16 bits

And computes checksum over entire object

UDP pseudo-Header

Source IP

Destination IP

Zero Protocol UDP Length

Page 121: Computer Networks Module III

Computer Networking / Module III/ AKN / 121

Checksum Calculation (contd.) Checksum calculation at the Sender end.

Add pseudo-header to the user datagram

Fill the checksum field with zeros

Divide the total bits in to 16 bit words

If total bytes are not even, add one byte of all zeros

Add all 16-bit sections using one‟s complement arithmetic

Complement the result and insert the result in checksum field

Drop the pseudo header and any padding used

Deliver the datagram

Checksum calculation at the Receiver end. Perform the operation same as above

If complement is zero drop pseudo-header and padding and accept the datagram. Otherwise discard the datagram

Page 122: Computer Networks Module III

Computer Networking / Module III/ AKN / 122

Checksum Calculation (contd.)

Assignment Calculate the checksum of the user datagram at sender side

and also test it for the receiver side

153.18.8.105

171.2.14.10

Zero 17 15

1027

U D P T

13

15 0

E S T padding

Page 123: Computer Networks Module III

Computer Networking / Module III/ AKN / 123

Checksum Calculation an example

Page 124: Computer Networks Module III

Computer Networking / Module III/ AKN / 124

Problem with Checksum Calculation Pseudo-header contains source and destination IP

addresses

i.e. IP addresses must be known at UDP layer

Destination IP address is supplied by the user.

But what about source IP, which is yet to be computed in IP layer? Solution 1: UDP software asks the IP layer to compute addresses

Solution 2: UDP software computes addresses and after checksum calculation sends it to IP layer.

IP layer need to fill remaining IP header fields

But any of the solution violates the abstraction of layers

i.e. It is clearly a compromise of pure separation needed for practical reasons

Page 125: Computer Networks Module III

Computer Networking / Module III/ AKN / 125

UDP Operation Connection less service

Each datagram sent by UDP is an independent datagram.

Data grams are not numbered, also there is no connection establishment thus different datagrams may follow different path

It cannot send a stream of data, i.e. each request must be small enough to fit into one user datagram

Flow and error control

No flow control hence no window mechanism. Receiver may overflow

No error control hence sender does not know if a message is lost or duplicated

Page 126: Computer Networks Module III

Computer Networking / Module III/ AKN / 126

• At sending side UDP accepts messages from different processes, differentiated by their port nos.Then it is passed to IP layer

• At receiving side UDP receives datagrams from IP. After error checking drops the header and delivers to the appropriate processes

In a host running a TCP/IP software, there is only one UDP but possibly several processes, that need to use services of UDP

Multiplexing and Demultiplexing

Port1 Port2 Port3

UDP DeMultiplexer

IP

Port1 Port2 Port3

UDP Multiplexer

IP

Page 127: Computer Networks Module III

Computer Networking / Module III/ AKN / 127

Well known ports used for UDP

Page 128: Computer Networks Module III

Computer Networking / Module III/ AKN / 128

Use of UDP

It is suitable for process that requires simple and fast request-response communication like DNS

Suitable for process with internal flow and error control mechanism like tftp

Suitable for multicasting

Used for management process such as SNMP

Used for route update protocols like RIP

Page 129: Computer Networks Module III

Computer Networking / Module III/ AKN / 129

Reliable Stream Transport Service Stream Orientation

Data is converted into stream of bits, divided into octets at source machines

The stream delivery service on the destination machine passes to the receiver exactly the same sequence of octets that the sender has passed.

Virtual Circuit Connection Before data transfer can start, both the

applications interact with their respective OS for a connection i.e. one application places a call, which must be accepted

by the other

Page 130: Computer Networks Module III

Computer Networking / Module III/ AKN / 130

Properties of Reliable Delivery Service During transfer, protocol software on the two machines continue

to communicate to verify that data is received correctly otherwise report the failure to appropriate S/W for necessary action

Therefore, Application programs view the connection as a dedicated H/W circuit.

The reliability is an illusion provided by the stream delivery service called virtual circuit

Buffered Transfer The protocol software is free to divide/combine the stream into

packets independent of pieces the application program transfers.

At the sending side, a PUSH mechanism forces protocol S/W to transfer all the data that has been generated without waiting to fill a buffer.

At the other end PUSH causes it to make the data available to application without delay

Page 131: Computer Networks Module III

Computer Networking / Module III/ AKN / 131

Properties of Reliable Delivery Service

Unstructured Stream TCP/IP stream service doesn‟t honour structured

data stream

i.e. There is no way for a payroll application to have the stream service mark the boundaries between employee records

Full Duplex Connection Connections provided by TCP/IP stream service

allow concurrent transfer on both directions

The advantage is control information for one stream can be send back to the source in datagrams carrying data in the opposite direction

Page 132: Computer Networks Module III

Computer Networking / Module III/ AKN / 132

Transmission Control Protocol Reliability

+ve acknowledgement with retransmission

Sender Receiver

Pkt Recv Pkt

Send AckRecv Ack

Send Pkt

The sender keeps a record of each

packet it sends and waits for an ack

before sending the next pkt

Sender also starts a timer and

retransmits a packet if the timer

expires before receiving the ack• Disadvantages

• Duplication of data / Ack due to premature retransmission

• To avoid confusion caused by delayed or duplicated Ack, seq. no. is

sent back with Ack

• Wasting of substantial amount of N/W bandwidth

Page 133: Computer Networks Module III

Computer Networking / Module III/ AKN / 133

END-to-END vs Point-to-Point 1. TCP needs an explicit connection establishment s.t.

two parties establish some shared state to enable the sliding window algorithm to begin

2. Variations in RTT are possible due to various reasons.(?) Therefore timeout mechanism that triggers retransmissions must be adaptive.

3. How late a packet can arrive at the destination? IP throws packets away after their TTL expires, TCP assumes that each packet has a max. segment life time(MSL). TCP has to be prepared for very old packets to suddenly show

up at the receiver, potentially confusing the sliding window algorithm.

Page 134: Computer Networks Module III

Computer Networking / Module III/ AKN / 134

END-to-END issues 4. In case of point-to-point link

delay bandwidth window size buffer space

The amount of resources dedicated to any one TCP connection highly variable, especially considering that any one host can potentially support hundreds of TCP connections at the same time

i.e TCP must include a mechanism that each side „learn‟ what resources the other side is able to apply to the connection

5. TCP connection has no idea what links will be traversed to reach at the destination.

The sending machine might be connected directly to a relatively fast Ethernet and somewhere in the middle a slower link has to traversed, which leads to „congestion‟

Page 135: Computer Networks Module III

Computer Networking / Module III/ AKN / 135

TCP Segment

TCP has three mechanisms to trigger the transmission of a segment

1. TCP maintains a variable, maximum segment Size (MSS), and it sends a segment as soon as it has collected MSS bytes from sending process

2. Sending process invokes push operation to effectively flush the buffer of unsent bytes

3. A timer that periodically fires; the resulting segment contains as many bytes as are currently in buffer

TCP is a byte oriented protocol.

i.e. It describes the service

provided to appl. process.

The pkts exchanged between

TCP peers are called segments

Appl process

TCP Send

buffer

Appl process

TCP Recv

buffer

segment segment

Write bytes Read bytes

Page 136: Computer Networks Module III

Computer Networking / Module III/ AKN / 136

TCP Segment Header Format

Sequence Number

HLen

Checksum

Options (variable length)

Data

. . .

Src Port

Acknowledgement

Padding

0 4 10 16 19 24 31

Dst Port

unused Flags Advertised window

Urgent pointer

Page 137: Computer Networks Module III

Computer Networking / Module III/ AKN / 137

TCP Header Format Explanation SrcPort and DstPort, identify the source and destination

application programs respectively

A TCP connection is identified by a 4-tuple {SrcPort, SrcIPAddr, DstPort, DstIPAddr}

Because TCP is a byte oriented protocol, each byte of data has a sequence number

SeqNum field contains the sequence number for the first octet of data carried in that segment

Ack field defines the octet number that is expected next

AdvertisedWindow contains the buffer space available at receiver

Sender Receiver

seqNum

Ack+advWin

Page 138: Computer Networks Module III

Computer Networking / Module III/ AKN / 138

TCP Header Format Explanation Flags: 6 bits, when set it is understood as follows

5. SYN: Synchronize seq. nos during connection

6. FIN: Terminate the connection

4. RESET: reset the connection

3. PUSH: request for push

1. URG: urgent pointer is valid

2. ACK:

Urgent pointer specifies the position, where the urgent data ends.

Options: TCP header can have 40 bytes of optional information

Page 139: Computer Networks Module III

Computer Networking / Module III/ AKN / 139

TCP Header Options

Max Seg Size(MSS): 4bytes determined at the time of connection establishment

Window Scale factor:3bytes

Used to increase the window size

New window size=window size 2scaleFactor

Largest value possible for scale factor is 16

i.e. 216 216 = 232 max size of seq. number

Time Stamp: 10 bytes

Used to calculate round trip time

Page 140: Computer Networks Module III

Computer Networking / Module III/ AKN / 140

Connection Establishment

The client sends a segment to the server stating (flags=SYN, seqNum=x )

Then server responds with a single segment that both acknowledges (Flags=ACK, Ack=x+1) and states it own beginning seqNum (Flags=SYN, seqNum=y)

Finally client responds with a third segment that acknowledges the server‟s sequence number (flags=ACK, Ack= y+1)

Client Server

The algorithm used is called

three-way-handshaking

Page 141: Computer Networks Module III

Computer Networking / Module III/ AKN / 141

Connection Termination, four-way-handshaking

Finally server sends a segment to the client stating (flags=FIN, seqNum=y )

The client responds with a segment that acknowledges the server‟s sequence number (flags=ACK, Ack= y+1)

Client Server The client sends a segment to the server stating (flags=FIN, seqNum=x )

Then server responds with a single segment that acknowledges (Flags=ACK, Ack=x+1)

now the connection is in half close mode. i.e. server can send data (remaining) but client can‟t

Page 142: Computer Networks Module III

Computer Networking / Module III/ AKN / 142

Connection Resetting

TCP may request for resetting a connection. i.e. the current connection is destroyed.

Resetting is done in one of the following three cases The TCP of one side has requested a connection to

a non-existent port. TCP of other side sends a segment with RST bit set

One TCP may want to abort the connection due to an abnormal situation

The TCP on one side may discover that the TCP on the other side has been idle for a long time

Page 143: Computer Networks Module III

Computer Networking / Module III/ AKN / 143

TCP State Transition

To keep track of all the different events during connection establishment to connection termination The TCP of both sides are implemented as a finite state machine and is represented in a state transition diagram

Notations

The states are shown using ovals

Transition from one state to another is shown using directed lines

Each line is contains two strings separated by slash. First string is input to TCP and second is output

Dotted lines represent server and solid lines represent client

Page 144: Computer Networks Module III

Computer Networking / Module III/ AKN / 144

State transition diagram

Starts in CLOSED state

When receives an Active open request from client application, it sends a SYN segment to server and goes to SYN-SENT state

Client TCP receives a SYN+ACK segment from server TCP. It sends an ACK to server TCP and goes to ESTABLISHEDstate

This is the data transfer state. Client remains in this state till data transmission continues

Client Diagram

Page 145: Computer Networks Module III

Computer Networking / Module III/ AKN / 145

State transition diagram contd.

Client TCP receives a close request from its application program. It sends a FIN segment to the other TCP and goes to FIN-WAIT-1 state

When the ACK is received from server TCP, it goes to FIN-WAIT-2 state. The connection is closed in one direction

Client receives a FIN segment from server TCP and sends an ACK and goes to TIME-WAIT state

When client TCP is in this state it starts a timer and waits till the timer goes off.

The value of this timer is set to double the MSL

The client TCP remains in this state to let all duplicate packets, if any arrive to be discarded. After the time-out the client goes to CLOSED state again

Client Diagram

Page 146: Computer Networks Module III

Computer Networking / Module III/ AKN / 146

State transition diagram contd.

Server TCP starts with CLOSED state

It receives a passive open request from the server application and goes to LISTEN state

IT now receives a SYN segment from the client TCP and sends a SYN+ACK segment to client TCP and goes to SYN-Rcvd state

It then receives ACK from client TCP and goes to ESTABLISHEDstate. Data transfer occurs between client and server applications

After data transmission it receives a FIN segment from client TCP, it now sends an ACK and goes to CLOSE-WAIT state

Server TCP receives a close request from server application program and sends a FIN segment to client TCP and goes to LAST-ACK state

When it receives the last ACK from client it goes to CLOSEDstate again

Server Diagram

Page 147: Computer Networks Module III

Computer Networking / Module III/ AKN / 147

TCP‟s Sliding Window 1. It guarantees the reliable delivery of data,

2. It ensures data is delivered in order and

3. It enforces flow control between sender and receiver

The algorithm places a small, fixed size virtual window on the stream sequence and transmits all octets that lie inside the window without receiving an Ack.

Three pointers are maintained into the send buffer

Sending Application

TCP

LastByteWritten

LastByteSent

Receiving Application

TCP

LastByteRead

LastByteRecvdNextByteExpectedLastByteAckd

Direction of transmission

Page 148: Computer Networks Module III

Computer Networking / Module III/ AKN / 148

Reliable and Ordered Delivery TCP on sending side maintains a send buffer, this

buffer is used to store data that has been sent but not yet acknowledged, as well as data that has been written by the sending application, but not transmitted

On other side, TCP maintains a receive buffer that holds data that arrives out of order, as well as the data that is in correct order but that application process has not yet read it

The relations among send buffer pointers can be as follows LastByteAckd LastByteSent and

LastByteSent LastByteWritten

bytes to the left of LastByteAcked and bytes to the right of LastByteWritten need not be saved

Page 149: Computer Networks Module III

Computer Networking / Module III/ AKN / 149

Reliable and Ordered Delivery

Similarly at the receive buffer

LastByteRead < NextByteExpected is true As a byte cannot be read by the application until it is received

NextByteExpected LastByteRecvd + 1

i.e. if data has arrived in order, NextByteExpected points to the byte after LastByteRecvd

if data has arrived out of order, NextByteExpected points to the start of the first gap in data

The bytes to the left of LastByteRead need not be buffered because they have already been read by the local process

bytes to the right of LastByteRecvd need not be buffered because they have not yet arrived.

Page 150: Computer Networks Module III

Computer Networking / Module III/ AKN / 150

TCP Flow Control

Both buffers are of finite size defined by MaxSendBuffer and MaxRcvBuffer.

Receiver sends a window advertisement that it can buffer. At receiving side, it maintains as

LastByteRecvd – LastByteRead MaxRcvBuffer to avoid overflowing its buffer, it therefore advertises a window size of

AdvertisedWindow = MaxrecvBuffer- ((NextByteExpected-1) -

LastByteRead) i.e. the free space remaining in receive buffer

NextByteExpected-1 is same as LastByteExpected in case of inorder receive, it will be different if out of order receive

If the receiving process is reading data just as fast as it arrives, then the advertised window stays open.

Page 151: Computer Networks Module III

Computer Networking / Module III/ AKN / 151

TCP Flow Control If the receiving process falls behind, then advertise

window shrinks and eventually goes to zero

On the other hand sender end TCP ensures that

LastByteSent – LastByteAcked AdvertisedWindow

i.e. it calculates How much data it can send as

EffectiveWindow = AdvertisedWindow – (LastByteSent –LastByteAcked) i.e. how much extra bytes it can send

Also sending side should ensure that the local process doesn‟t overflow the send buffer, that is

LastByteWritten – LastByteAcked MaxSendBuffer

i.e. if sending process tries to write y bytes and (LastByteWritten – LastByteAcked) + y > MaxSendBuffer then TCP blocks sending process to generate more data

Page 152: Computer Networks Module III

Computer Networking / Module III/ AKN / 152

TCP Flow Control How does the sending side know that the advertised

window is no longer zero?

i.e. once the receiver side has advertised a window size of 0, the sender is not permitted to send any more data, which mince it has no way to discover that the advertised window is no longer zero at some time in the future.

Solution: the sending side persists in sending a segment with one byte of data every so often. The data may not be accepted but eventually it gets a response whenever send buffer becomes free.

The size of MSS is set to MTU of the directly connected network minus the size of TCP and IP header s.t. can be sent without fragmentation

Page 153: Computer Networks Module III

Computer Networking / Module III/ AKN / 153

Adaptive Retransmission

TCP retransmits each segment if an Ack is not received in a certain period of time(RTT)

But choosing an appropriate timeout value is very difficult and TCP uses adaptive retransmission mechanism

Original Algorithm:

TCP sends a data segment, records the time. When Ack for that segment arrives, it reads the time again. Difference between two times gives a SampleRTT.

TCP then computes a weighted average between the previous estimate and this new sample as

EstimatedRTT = EstimatedRTT + (1 - ) SampleRTT

between 0.8 and 0.9 used to smooth the EstimatedRTT

Page 154: Computer Networks Module III

Computer Networking / Module III/ AKN / 154

Adaptive Retransmission Then TimeOut = 2 EstimatedRTT

Problems Ack does not acknowledges a transmission but receipt of data. i.e. it is

difficult to associate an ACK with an transmission or retransmission

Associating the ACK with original transmission may be an over estimate and associating with retransmission may be an under estimate as shown in two figures

Solution?

Sender Receiver Sender Receiver

Original transmission Retransmission

Page 155: Computer Networks Module III

Computer Networking / Module III/ AKN / 155

Congestion Control Congestion is a situation which may occurs when the load on

the network is greater than the capacity of the network

i.e. The number of packets sent to the router is much more then the Number of packets the router can handle.

Router has so many packets queued that it runs out of buffer space and has to start dropping packets, which is a worst condition

Therefore to control the congestion we try to avoid heavy data traffic that may cause congestion

If the rate of packet arrival rate is higher than

processing rate then input queues becomes longer

If the rate of packet departure rate is higher than

processing rate then output queues becomes longer

Page 156: Computer Networks Module III

Computer Networking / Module III/ AKN / 156

Traffic descriptors

Average data rate = amount of data/total time

Peak datarate= max datarate of the traffic

Max. burst size= max length of time the traffic is generated at the peak rate

Effective bandwidth= is a function of average datarate, peak data rate, and max. burst size

Page 157: Computer Networks Module III

Computer Networking / Module III/ AKN / 157

Traffic Profiles

Constant-bit-rate traffic:

Datarate is constant throughout

Variable bit rate:

The rate of data flow changes in time

Bursty:

The datarate changes suddenly in a

very short period of time. This type of traffic

creates congestion in a network.

Page 158: Computer Networks Module III

Computer Networking / Module III/ AKN / 158

Network performance Delay vs Load

When load is much less than the capacity of

the network, the delay is at a minimum

Delay composed of propagation delay and

processing delay, which is negligible!

When load reaches the network capacity, the

delay increases sharply because waiting time

is added to the delay

Throughput vs Load

Throughput is the number of packets passing

through the network in unit time

when the load is below capacity, the

throughput increases proportionally with load

When load reaches the network capacity,

throughput declines sharply due to discarding

of packets followed by retransmissions further

makes things worse

Page 159: Computer Networks Module III

Computer Networking / Module III/ AKN / 159

Congestion Control Two categories of mechanisms for congestion control

Open Loop: congestion prevention

Closed Loop: congestion removal

Open Loop: preventing congestion

Retransmission policy The retransmission policy and retransmission timers must be designed to

optimize the efficiency and to prevent congestion

Window Policy The selective repeat is better than Go-Back-N policy for congestion

control?

ACK Policy If ACK is not received, sender slows down, help prevent congestion

Discarding Policy Selective discarding of less sensitive packets when likelihood of

congestion increases

Admission Policy Before admitting for a flow it checks the resources

Page 160: Computer Networks Module III

Computer Networking / Module III/ AKN / 160

Congestion Control: closed Loop

Closed Loop: removal of congestion, if occurs Back Pressure

Router informs previous routers to slow down (recursive)

Choke Point

Router informs source to slow down by sending a special packet

Implicit Signaling

Source predicts about congestion and slows down (like delay in getting ACK)

Explicit Signaling

Router sends an explicit signal by setting a bit in the packet

Backward signaling:The bit can be set in a packet moving in the opposite direction. This bit warns the sender to slow down

Forward signaling:The bit can be set in a packet moving in the direction of congestion. This bit warns the destination to slow down. Receiver slows down sending ACK

Page 161: Computer Networks Module III

Computer Networking / Module III/ AKN / 161

Congestion Control TCP

When congestion occurs in a router and some packets might be dropped, then sender retransmits those packets. This may create more congestion and more dropping of packets.

The condition become so worse that the system can pass no more data. This situation is called congestion collapse

i.e. If the cause of the lost segment is congestion, retransmission of the segment does not remove the cause—it aggravates it.

To avoid this situation, TCP assumes that the cause of a lost segment is due to congestion in the network and takes necessary action to remove congestion.

Page 162: Computer Networks Module III

Computer Networking / Module III/ AKN / 162

Congestion Control TCP contd.

The window size is decided not only by the receiver‟s advertisement but also by congestion in the network

Actual Window = Min(receiver‟s window, Congestion window)

Congestion avoidance

To avoid congestion we have two strategies

Slow start and additive increase till there is no congestion

Multiplicative Decrease, if congestion occurs

Page 163: Computer Networks Module III

Computer Networking / Module III/ AKN / 163

Congestion avoidance Slow start

At the beginning of a connection TCP sets the congestion window size = 1MSS

For each segment ACK it receives the congestion window size is increased by 1 MSS till it reaches a threshold value = ½ of allowable window size i.e.

ACK for 1 seg –> congestion window size = 2 MSS

ACK for 2 segs -> congestion window size = 4 MSS

ACK for 4 segs -> congestion window size = 8 MSS

. . . -> congestion window size = ½ advt. Window

Additive Increase After the size reaches the threshold, it increases the size by

one for each received ACK.

i.e. ACK may be received for several segments but increase is only by 1 MSS

Page 164: Computer Networks Module III

Computer Networking / Module III/ AKN / 164

Congestion avoidance This strategy continues till it receives ACK before time-out or

congestion window size = advt. Window size.

Multiplicative Decrease The only way to guess that a congestion has occurred is

through a lost segment. i.e. if the sender does not receive ACK before time-out

If congestion occurs than threshold value is set to ½ of congestion window and congestion window is set to 1MSS again

Page 165: Computer Networks Module III

Computer Networking / Module III/ AKN / 165

Congestion control in frame relay

Frame relay is designed for high throughput and low delay but congestion decreases throughput and increases delay

Frame relay does not have flow control, but allows user to transmit bursty data that can cause congestion

For congestion avoidance, Frame relay protocol uses 2 bits the frame to warn the source and destination about the congestion.

Backward Explicit congestion Notification (BECN) bit

Forward Explicit congestion Notification (FECN) bit

Page 166: Computer Networks Module III

Computer Networking / Module III/ AKN / 166

BECN bit It warns the sender about congestion in the

network using two methods

Method 1: the switch uses response frames from the receiver

Method 2: the switch can use a predefined connection, DLCI=1023 to send special frames for this specific purpose

Sender responds by reducing data rate

Page 167: Computer Networks Module III

Computer Networking / Module III/ AKN / 167

FECN bit Used to warn the receiver about the congestion

If there is an ACK mechanism at the higher level the receiver can delay the ACK, thus forcing the source to slow down

Four cases of congestion in Frame Relay

Page 168: Computer Networks Module III

Computer Networking / Module III/ AKN / 168

Quality of Service (QoS)

Is an assurance from the network for a particular kind of service

e.g. network uses retransmission strategy to make sure that data arrives correctly.

This service is ok for non-real time application. But may not be ok for real-time applications as it does-not guarantee timeliness

i.e. we need a new service model in which, application that need higher assurances can ask the network for that

A network that can provide these different level of services is said to support QoS.

Page 169: Computer Networks Module III

Computer Networking / Module III/ AKN / 169

Flow characteristics Reliability

Lack of reliability means losing a packet or ACK, which may or may not needs retransmission

Example: Email, file transfer needs retransmission

Audio and video may not need retransmission

Delay (Source-to-destination delay) Application can tolerate delay in different degrees

Example: multimedia application need minimum delay, but in case of file transfer or email it is less important

Jitter Is a variation in delay for packets belonging to same flow.

Audio and Video cannot tolerate high jitter

No effect for file or mail transfer

Bandwdth Different application needs different BW

In video transmission we need million of bits to refresh a color screen

While total no of bits in an email may not reach even a million

Page 170: Computer Networks Module III

Computer Networking / Module III/ AKN / 170

Techniques to Improve QoS Common methods are scheduling, traffic shaping,

admission control,and resource reservation

Scheduling (FIFO, priority and weighted fair queuing) When packets from different flows arrive at a router, It is

needed to treat the different flows in a fair and appropriate manner. Some techniques are as follows

FIFO Queuing with tail drop In this queuing, packets wait in a buffer until the node is ready to

process them

If average arrival rate is higher than the average processing rate, the queue will fill up and new packets will be discarded without regard to which flow the packet belongs to or how important the packets is?

It is simplest and most widely used in Internet routers

Page 171: Computer Networks Module III

Computer Networking / Module III/ AKN / 171

Scheduling Techniques contd. Priority Queuing

Each packet is marked with a priority class

The router implements multiple FIFO queues, one for each priority class

It processes packets of higher priority first and moves on to the next priority if the higher priority one is empty

If there is a continuous flow in a high priority queue, then this will create a starvation problem in others

Therefore this should be optimized to put hard limits on how much high priority traffic can be inserted in the queue

These scheduling is used in Internet to protect most important packets like routing updates

Page 172: Computer Networks Module III

Computer Networking / Module III/ AKN / 172

Scheduling Techniques Weighted fair Queuing

The packets are still assigned to different classes before inserting to the queues

The router than serves queues in around-robin fashion according to the weight of the queue

i.e. for above example: 3 pkts from first, two from 2nd and one from 3rd queue

Page 173: Computer Networks Module III

Computer Networking / Module III/ AKN / 173

Traffic shaping Is a mechanism to control the amount and the rate of the

traffic sent to the network.

Two techniques used 1. Leaky Bucket, 2. Token Bucket

Leaky Bucket

The idea is to have a constant bit rate traffic in the network in spite of bursty data coming from source.

i.e. if a bucket has a

small hole at the bottom, the water leaks from the bucket at a constant rate and is independent of the rate of input to the bucket

Page 174: Computer Networks Module III

Computer Networking / Module III/ AKN / 174

Leaky bucket implementation When the packets are of same fixed size then one packet can

be pushed to network per clock tick

If packets are of variable size than more packets per tick may be allowed.

i.e. if rule is 1024 bytes per tick then one 1024 byte packet is allowed per tick, two 512 bytes per tick and four 256 byte packets per tick and so on

Algorithm for each clock tick{

1. Initialize a byte counter to n

2. while n size of the packet

3. send the packet and decrement the counter by the packet size.

4. Stop the transmission till next tick

}

Where n is max number of bytes allowed per tick

Page 175: Computer Networks Module III

Computer Networking / Module III/ AKN / 175

Leaky bucket contd. A leaky bucket algorithms shapes bursty traffic into fixed-rate

traffic by averaging the data rate. The packets will be dropped if the buffer is full

This algorithm prevents congestion by avoiding instantaneous heavy traffic at the output line

The buffer capacity should be carefully designed s.t. it should be able to store the bursty data for short period of time, otherwise packets will be dropped

Example: data comes at a rate 25 Mbps, one 40ms burst every second. Design the

leaky bucket

Solution: total data per sec = 25Mbps * 40 *10-3 = 1Mb

Thus capacity of buffer can be chosen as 1Mb

Uniform output rate may be chosen as 2Mbps, s.t. it will take 500ms to drain the complete data

Page 176: Computer Networks Module III

Computer Networking / Module III/ AKN / 176

Token Bucket The leaky bucket is restrictive. i.e. if a host is idle then bucket

becomes empty, if the host has bursty data then bucket allows only an average rate.

But the token bucket algorithm allows idle hosts to accumulate credit for the future in form of tokens

Algorithm: token bucket holds tokens generated by a clock at the rate of one token per

T sec or n tokens per sec

It consumes one token per packet sent i.e. to send a packet there should be a token available in the bucket

Page 177: Computer Networks Module III

Computer Networking / Module III/ AKN / 177

Token Bucket contd. Leaky bucket and Token Bucket provides different kind of

traffic shaping The Leaky bucket algorithm does not allow idle hosts to save up

permission to send large bursts later

But the token bucket algorithm does allow saving, up to the max size of bucket. i.e. bursts upto the size of bucket can be sent at once

The token bucket algorithm throws away tokens when the bucket fills up but never discard packets.

But the Leaky bucket discards packets when bucket fills up

One variation to Token bucket Each token represent the right to send k bytes in place of one

packet.

A packet can only be sent if enough tokens are available to cover length in bytes. Fractional tokens are kept for future use

Page 178: Computer Networks Module III

Computer Networking / Module III/ AKN / 178

Quality of Service (QoS)

Two models have been proposed to provide Quality of Service in the Internet Integrated Services (IntServ)

Is a flow based QoS model designed for IP. i.e. a user needs to create a flow, a kind of virtual circuit, from the source to destination and inform all routers about the resource requirement.

Differentiated Services (DiffServ) Is a class based QoS model designed for IP. i.e.

the applications, or hosts, define the type of service they need each time they send a packet.

Page 179: Computer Networks Module III

Computer Networking / Module III/ AKN / 179

Integrated services features Signals

IP is a connection less protocol

To implement a flow based service a signaling protocol is used to run over IP that provides the signaling mechanism for making reservation

The protocol is named as Resource Reservation Protocol

Flow Specification has two parts: Rspec and Tspec

Rspec(resource specification) Defines the resource that the flow needs to reserve (buffer, bw etc.)

Tspec(Traffic specification) Traffic characterization of the flow

Admission After receiving flow specification the router decides to admit or

deny the flow

Page 180: Computer Networks Module III

Computer Networking / Module III/ AKN / 180

Integrated services features Two service classes are defined

Guaranteed Service Class Designed for real time traffic that needs guaranteed

minimum end-to-end delay. (multimedia)

end-to-end delay = sum of delays in routers + propagation delay + setup mechanism

Only delay in router can be guaranteed by router

The amount of end-to-end delay and the data rate must be defined by the application

Controlled-Load Service Class Designed for applications that can accept some delays, but

are sensitive to an overload network and to the danger of losing packets

Example application are file transfer, email etc.

Page 181: Computer Networks Module III

Computer Networking / Module III/ AKN / 181

Resource ReserVation Protocol (RSVP) The resource reservation protocol is a signaling

protocol to help IP create a flow and consequently make a resource reservation

The signaling system of RSVP is designed for multicasting to enable it to provide resource reservation for all kinds of traffic including multimedia, which often uses multicasting

In this case the receivers (not the sender) makes the reservation

It has several types of messages for above tasks. Two of them are used for resource reservation, i.e. Path message and Resv message

Page 182: Computer Networks Module III

Computer Networking / Module III/ AKN / 182

RSVP Path message A Path message travels from the sender and reaches

all the receivers (downstream) in multicast path

On the way path message stores the necessary information for the receivers.

A new message is created when the path diverges.

Page 183: Computer Networks Module III

Computer Networking / Module III/ AKN / 183

RSVP Recv message

Reservation merging Resources are not reserved for each receiver in a

flow.

Reservation is merged to larger of the two (or more) requests

As different qualities for multimedia is required by different receivers, thus different requirements for the same flow

Receiver sends a recv message, which travels towards sender (upstream) and makes a resource reservation on the routers that support RSVP

If a router does not support RSVP on the path, it routes packet using traditional delivery methods

Page 184: Computer Networks Module III

Computer Networking / Module III/ AKN / 184

Reservation Styles When there are more than one flow, the router needs

to make a reservation to accommodate all of them

RSVP defines three types of reservation styles Wild card Filter: router creates a single reservation

for all senders based on largest request. This is used when flow from different receivers do not occur at the same time

Fixed Filter: router creates a distinct reservation for each flow. It is used when there is a high probability that from different receivers occurs at the same time

Shared Explicit: creates a single reservation which can be shared by a set of flows

Page 185: Computer Networks Module III

Computer Networking / Module III/ AKN / 185

Differtiated services Problems with integrated services

Scalability This model requires that each router keep information for

each flow, which is impractical as load on routers will increase

Service type limitation It provides two services 1. Guaranteed and control load

Solutions The routers do not have to store information about flows.

i.e. The applications, or hosts, define the type of service they need each time they send a packet

The per-flow service is changed to per class service.

The router routes the packet based on the class of service

This is called Differentiated services

Page 186: Computer Networks Module III

Computer Networking / Module III/ AKN / 186

Differentiated service features Each packet contains a field called DS field.

The value of this field is set by the first router designated as the boundary router.

contains two sub-fields:

Differentiated services code point: defines per hop behavior (PHB) and an unused field

DE PHB(default PHB) same as TOS.

EF PHB (expedited forwarding) provides following services like Low loss, Low latency, Ensured bandwidth.

AF PHB (Assured forwarding) delivers the packet with a high assurance as long as the class traffic does not exceed the traffic profile of the node. The users of the network need to be aware that some packets may be discarded

Page 187: Computer Networks Module III

Computer Networking / Module III/ AKN / 187

Traffic conditioner The DS node uses traffic conditioners like

Meters: checks to see if the incoming flow matches the

negotiated traffic profile

Marker: can remark a packet that is using best-effort delivery

or down-mark a packet based on information received from

the meter.

Shaper: reshapes the traffic if not compliant with negotiated

traffic

Dropper: discards a packet if flow severely violates the

negotiated profile

Page 188: Computer Networks Module III

Computer Networking / Module III/ AKN / 188

END of module III

Thank You