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

Merged CN

The document discusses medium access control (MAC) protocols for computer networks. It begins by explaining that MAC protocols determine how nodes access a shared broadcast channel when there is competition. It then covers several static and dynamic MAC protocols: Static protocols like FDMA and TDMA divide bandwidth into fixed portions. Dynamic protocols like ALOHA and carrier sense multiple access (CSMA) allow nodes to access the channel dynamically. Variations of ALOHA and CSMA are discussed, including how they aim to reduce collisions and improve efficiency of channel access. The document concludes by explaining the CSMA/CD protocol used in Ethernet, which allows nodes to detect collisions while transmitting and abort transmissions to avoid wasting bandwidth.

Uploaded by

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

Merged CN

The document discusses medium access control (MAC) protocols for computer networks. It begins by explaining that MAC protocols determine how nodes access a shared broadcast channel when there is competition. It then covers several static and dynamic MAC protocols: Static protocols like FDMA and TDMA divide bandwidth into fixed portions. Dynamic protocols like ALOHA and carrier sense multiple access (CSMA) allow nodes to access the channel dynamically. Variations of ALOHA and CSMA are discussed, including how they aim to reduce collisions and improve efficiency of channel access. The document concludes by explaining the CSMA/CD protocol used in Ethernet, which allows nodes to detect collisions while transmitting and abort transmissions to avoid wasting bandwidth.

Uploaded by

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

Application

Logical Link Control (LLC)


Transport
Network
Data Link
Physical
Media Access Control (MAC)

Computer Networks
Medium Access Control

Dr. Subhrendu Chattopadhyay


Department of CSE
SRM University-AP
Overview
• In broadcast networks (Multi-access/random-access channels)
a) The key issue is how to determine who gets to use the channel when there is
competition for it.
b) MAC=Protocol to determine who goes next on channel.
c) It’s important for LANs(Bus topology, WiFi), WANs are point-to-point.

• How to allocate a single broadcast channel among competing


users ??
• Can be done using :
a) Static Channel Allocation.
a) FDM and TDM.
b) Dynamic Channel Allocation.
a) ALOHA and Carrier Sense Protocols.
Static Channel Allocation(FDMA)
• Let’s say N users exist:
• the available bandwidth is divided into N equal-sized portions.
• Each user is assigned to one portion(1/N).
• Since each user has a private frequency band
• there is no interference among users.
• Example : Wireless FM radio channels (Each station gets a portion of the
FM band and uses it most of the time to broadcast its signal.)

• Static channel allocation is efficient when :


• Number of users are less than available channels.
• Data transmission should have steady stream.

• Inefficient to divide into fixed number of chunks.


• May not all be used, or may need more.
• Doesn't handle bursty traffics of computer systems.
Static Channel Allocation(TDMA)
• In a time slot only 1 user transmits (or receives).
• Several users share a single frequency channel.
• Transmission is non-continuous.
• Power consumption is lower than FDMA (e.g., the transmitter can be
turned off when idle)
• Synchronization is needed
Dynamic channel allocation
• Assumptions:
a) Station Model: Assumes that each of N "stations" (packet generators,
Terminal) independently produce frames. The station generates no new frame
until that previous one is transmitted.

b) Single Channel Assumption: There's only one channel; all stations are
equivalent and can send and receive on that channel.

c) Collision Assumption: If two frames overlap in any way time-wise, then that's
a collision. Any collision is an error, and both frames must be retransmitted.
Collisions are the only possible error.

d) Continuous/ Slotted Time: Time is not in discrete chunks. Frame transmission


can begin at any instant. Alternatively, in slotted, frame transmissions always
begin at the start of a time slot. Any station can transmit in any slot (with a
possible collision.)

e) Carrier/No-Carrier Sense: Stations can tell a channel is busy before they try
it. NOTE - this doesn't stop collisions.
Multiple Access Protocols: ALOHA
ALOHA
a) Developed in Hawaii in the 1970s.
❶ PURE ALOHA:
b) Every station transmits whenever it wants to.
c) Colliding frames are destroyed. The sender knows if its frame got destroyed
using feedback property, and if so waits a random time and then retransmits.
d) ANY overlap is a collision.
e) Best efficiency if frames are same size.
f) A contention system: Multiple users share a common channel that can lead to
conflict.
Pure Aloha(2)
Multiple Access Protocols: ALOHA

ALOHA : Performance
a) collision probability increases:
b) pkt sent at t0 collide with other pkts sent in [t0-1, t0+1]

P(success by given node) = P(node transmits) .


P(no other node transmits in [t 0-1,t0] .
P(no other node transmits in [t 0,t0 +1]
c) Very inefficient : Maximum achievable Throughput (18%)
Slotted Aloha
• Time is divided into equal size slots (= packet trans. time)
• Node with new packet: transmit at beginning of next slot.
• If collision: retransmit packet in future slots with probability p, until
successful.

Success (S), Collision (C), Empty (E) slots


Slotted ALOHA

Slotted ALOHA is twice as efficient as pure ALOHA


a) Low load wastes slots, high loads causes collisions
b) Efficiency up to 37% (almost twice to PURE ALOHA)

Comparison of the channel utilization versus load for various


random access protocols.
Carrier Sense Multiple Access Protocols
• CSMA protocol was developed to overcome :
• the problem in pure ALOHA and slotted ALOHA.
• i.e. to minimize the chances of collision.

• CSMA protocol is based on the principle of ‘carrier sense’. ("sense


before transmit" or "listen before talk).
• Carrier Sense – the ability of a network card to sense or detect
communication on the network.
• Multiple Access – states that in that network there are multiple stations
that could access the network at the same time.

• The chances of collision can be reduce to great extent if a station senses


the channel before trying to use it.

• Although CSMA can reduce the possibility of collision, but it cannot


eliminate it completely.
Carrier Sense Multiple Access Protocols

• There are three different types of CSMA protocols :-


(i) 1-Persistent CSMA
(ii) Non-Persistent CSMA
(iii) P-Persistent CSMA
1-Persistent CSMA
• When a station has data to send :
• it first listens(carrier sense) to the channel to see if anyone else is
transmitting at that moment.
• If the channel is idle:
• the stations sends its data(frame).
• If the channel is busy :
• the station just waits until the channel becomes idle.
• Later, the station start transmitting a frame.
• If a collision occurs :
• the station waits a random amount of time and starts all over
again.
• The protocol is called 1-persistent because the station transmits
with a probability of ‘1’ when it finds the channel idle.
CSMA collisions (Propagation delay)
1-Persistent CSMA
• Effect of propagation delay in CSMA :
• If a signal from station A has not reached to station B and station
B is ready to send, it will sense the channel to be idle and send its
frame.

• Collision can be there even when propagation delay is zero and


carrier sense is also there.
• If stations B and C become ready in the middle of A’s
transmission, B and C will wait until the end of A’s
transmission and then both will begin transmitted
simultaneously, resulting in a collision.

• If B and C were not so greedy, there would be fewer collisions.


Non-Persistent CSMA
• when a station is ready to send a frame , it senses the channel :
• if busy : waits for random time rather than continuously sense it
for the purpose of seizing it.
• if idle : sends it.
• if collision : waits for random time and tries again.

• Less greedy than 1-persistent, hence better channel utilization but


longer delays.
• Reduced collision rate in comparison with 1-persistent CSMA.

Random Waiting
times

Wasted time
Non-Persistent CSMA

• Advantages of non-persistent CSMA:


• Less greedy than 1-persistent.
• It reduces the chances of collision because the stations wait a
random amount of time before transmitting.

• Disadvantages of non-persistent CSMA:


• Longer delays : This is due to the fact that the stations wait a
random amount of time before transmitting.
P-Persistent CSMA
• Time is divided into slots where each Time unit (slot) is typically
equals to maximum propagation delay
• Station wishing to transmit listens to the medium:
• If medium idle,
• transmit the frame with probability (p), OR
• wait one time unit (slot) with probability (1 – p), then repeat 1.
• If medium is busy, continuously listen until idle and repeat step 1
• Performance :
• Reduces the possibility of collisions like 1-persistent.
• Reduces channel idle time like non-persistent
P-Persistent CSMA
Persistent and Nonpersistent CSMA

Comparison of the channel utilization versus load for various random


access protocols.
CSMA/CD
• CSMA with collision detection.
• Problem: when frames collide, medium is unusable
for duration of both (damaged) frames.
• For long frames (when compared to propagation
time), considerable waste.
• What if station listens while transmitting?
Ethernet CSMA/CD
• Use any persistent CSMA for frame transmission.
• Transmit packet only if channel is sensed idle.
• During the packet transmission, the node’s computer hardware
monitors(listens) its own transmission to see if the packet has
experienced a collision.
• An additional XOR gate is implemented at the transmitter.

• If received signal XOR with transmitted signal is “0” then no


collision.
• If received signal XOR with transmitted signal is “1” then there is

a collision.
• Stop the ongoing frame transmission(when XOR=1).

• Collisions are detected within a few bit times.

• Transmission is then aborted, reducing the channel wastage

considerably.
• Sends a jamming signal to all of its neighbour stations.
CSMA/CD collision detection
Collision and abortion in CSMA/CD
CSMA/CD
CSMA/CD Performance
• Wasted capacity is restricted to time to detect collision.
• Time to detect collision < 2*maximum propagation delay.

• Rule in CSMA/CD protocols: frames are long enough to allow


collision detection prior to end of transmission.
• Assumption : Transmission time is equal to maximum propagation time.

• What happens if the collision detection happens after transmission


time ?
• This case is true if collision happens close to the receiver.
• A jamming Signal will be broadcasted in the shared medium
• Nodes that receive the jamming signal will wait for backoff time.
Collision Free Protocols

• Pure ALOHA, slotted ALOHA, CSMA and


CSMA/CD are contention based protocols
– try. If collide, retry.
– No guarantee of performance.
– What happens if the network load is high?
• Collision free protocols:
– pay constant overhead to achieve performance
guarantee
– Good when network load is high
Collision Free
World
• Provides in order access to shared
medium so that every station has chance
to transfer (fair protocol)
• Eliminates collision completely.
• Three methods for controlled access:
– Reservation (Bitmap protocol)
– Polling
– Token Passing
Reservation – Bit Map Protocol
• Two rounds of transmission cycle
• First Round (Contention Period)
• Consists of N slots each reserved for a particular station
• In this period, each station transmits
• 1 if it has a frame to transmit
• 0 if it has no frame to transmit
• At the completion of the first round everybody knows who wants to
transmit
• Second Round (Transmission Period)
• Stations transmit according to the order formed in the first round
• There will not be any collisions
Bit Map - Reservation
Based
• When a station needs to send a data frame, it
makes a contention in its own 1-bit mini-slot.
• By listening to the contention interval, every
station knows which stations will transfer
frames, and in which order.
• The stations that made reservations can send
their data frames after the reservation frame.
Token Ring

• Token pass.
• There is only one token in the network.
• The token is passed through every node in the network.
• Only the node that has the token can transfer data.
Token Ring: Issues

Source Problems:
● Orphan Packet Problem: If source station shuts down then the data transmitted by the source will
remain circulating
● Stray Packet Problem: Data get corrupted in such a manner that sender can’t recognize it.
Destination Problems:
● If the Destination is Busy:
● If the Destination is Down:
● If there is some error in the Data:
Token Problem:
● Captured Token Problem:
● If Token is lost/corrupted:
Monitor Problems:
● Monitor missing:
● Monitor Malfunctioning:
Binary Countdown

The binary countdown protocol. A dash indicates silence.


Contention vs. Collision-Free
• Contention better under low load. Why?
• Less collisions under low load.
• Collision-free better under high load. Why?
• Channel utilization is better at high load.
• How about combining their advantages -- limited
contention protocols.
• Behave like the ALOHA scheme under light load
• Behave like the bitmap scheme under heavy load.
Limited contention protocols

a) collision based protocols (ALOHA,CSMA/CD) are good when the


network load is low.
b) collision free protocols (bit map, binary countdown) are good when
load is high.
c) How about combining their advantages -- limited contention protocols.
a) Behave like the ALOHA scheme under light load
b) Behave like the bitmap scheme under heavy load.
Limited contention protocols:
a) adaptive tree walk protocol
a) trick: partition the group of station and limit the
contention for each slot.
a) under light load, every one can try for each slot like aloha
b) under heavy load, only a small group can try for each slot
c) how do we do it
a) treat stations as the leaf of a binary tree.
b) first slot (after successful transmission), all stations (under
the root node) can try to get the slot.
c) if no conflict, fine.
d) if conflict, only nodes under a subtree get to try for the next
one. (depth first search)
Example: 0

1 2

3 4 5 6

A B C* D E* F* G H*

Slot 0: C*, E*, F*, H* (all nodes under node 0 can try), conflict
slot 1: C* (all nodes under node 1 can try), C sends
slot 2: E*, F*, H*(all nodes under node 2 can try), conflict
slot 3: E*, F* (all nodes under node 5 can try), conflict
slot 4: E* (all nodes under E can try), E sends
slot 5: F* (all nodes under F can try), F sends
slot 6: H* (all nodes under node 6 can try), H sends.
Motivation for Wireless MAC
• Can we apply media access methods from fixed networks?
• Example CSMA/CD
a) Carrier Sense Multiple Access with Collision Detection
b) send as soon as the medium is free, listen into the medium if a collision
occurs (original method in IEEE 802.3)
• Problems in wireless networks
a) Signal strength decreases proportional to the square of the distance
b) Sender would apply CS and CD, but the collisions happen at the receiver
(Hidden terminals)
c) it might be the case that a sender cannot “hear” the collision, i.e., CD
does not work
Hidden and Exposed Terminals
• A wants to transmit
to B.
• C senses channel – no
idea A is transmitting.
• C initiates
A B transmission to F.
F • Collision at B. – C and
C
A are hidden from
D each other.

• D could potentially transmit to E but does not – senses A’s


carrier. D is exposed to A. Loss in throughput.
Hidden and exposed terminals
• Hidden terminals
a) A sends to B, C cannot receive A
b) C wants to send to B, C senses a “free” medium (CS fails)
c) collision at B, A cannot receive the collision (CD fails)
d) A is “hidden” for C

• Exposed terminals
A B C
a) B sends to A, C wants to send to another terminal (not A/B)
b) C has to wait, CS signals a medium in use
c) but A is outside the radio range of C, therefore waiting is not necessary
d) C is “exposed” to B
MACA - collision avoidance
• No carrier sense (CS)
• MACA (Multiple Access with Collision Avoidance) uses short signaling
packets for collision avoidance
a) RTS (request to send): a sender request the right to send from a receiver with a short
RTS packet before it sends a data packet
b) CTS (clear to send): the receiver grants the right to send as soon as it is ready to receive
• Signaling packets contain
a) sender address
b) receiver address
c) packet size
• Variants of this method can be found in IEEE 802.11.
MACA examples
• MACA avoids the problem of hidden terminals
a) A and C want to
send to B
b) A sends RTS first
c) C waits after receiving
RTS
CTS from B
CTS CTS
A B C
• MACA avoids the problem of exposed terminals?
a) B wants to send to A, C
to another terminal
b) now C does not have
to wait for it cannot
receive CTS from A
RTS RTS

CTS
A B C
Alternative Approach: MACAW
• No carrier sense, no collision detection
• Collision avoidance:
a) Sender sends RTS
b) Receiver sends CTS
c) Sender sends DATA
d) Receiver sends ACK
• Backoff mechanism:
a) Exponential backoff with significant changes for improving fairness
and throughput
MACA
• A sends out RTS and set a timer and waits for CTS
• If A receives CTS before timer go to zero, OK! sends data packet
• Otherwise, A assumes there is a collision at B
• Double the backoff counter interval
• Randomly pick up a timer from [1,backoff counter]
• Send next RTS after timer go to zero
• B sends out CTS, then set a timer and waits for data packet
• If data packet arrives before timer go to zero, OK!
• Otherwise, B can do other things
• C overhears A’s RTS, set a timer which is long enough to allow A to receive
CTS. After the timer goes to zero, C can do other things
• D overhears B’s CTS, set a timer which is long enough to allow B to receive
data packet.
• E overhears A’s RTS and B’s CTS, set a timer which is long enough to allow B
to receive data packet.
• RTS and CTS can also contain info to allow sender A to adjust power to reduce
interference
Ethernet Cabling
Type Cable Max Seg. Nodes/seg Remark
– 10Base5: Thick coax 500m 100 Original cable/ obsolate
– 10Base2: Thin Coax 185 m 30 No hub Needed
– 10BaseT: Twisted Pair 100 m 1024 cheapest system
– 10BaseF: Fiber Optics 2000m 1024 Best between buildings

• Repeater: receive, amplify and retransmit signals in both directions.


• used for thick and thin coax cables to connect multiple segments.
• Hub: logically connects UTP cables into 1 long ethernet cable
• may contain electronics to detect and disconnect faulty UTP and also
reshapes the signals
Ethernet Cabling
• 10Base5 (Thick Ethernet)
a) 10Mbps
b) Base: Baseband transmission (digital Signals)
c) Its max segment length = 500 m
• Thick Coax
a) Advantages: Low attenuation, excellent noise immunity, superior mechanical
strength
b) Disadvantages: Bulky, difficult to pull, transceiver boxes too expensive.

* Wiring represented a significant part of total installed cost.


AUI: Attachment unit
interface cable
MAU Connectors:
Multistation Access Unit

MAU device is physically


hooked on main cable.

50 meter AUI cable from


MAU to station.
Ethernet Cabling
• 10Base2 (Thin Ethernet) Cheapernet
a) 10 Mbps
b) 185 meter segment length
c) Signal-regenerating repeaters
d) Transceiver was integrated onto the adapter
e) Thin Coax (coax thinner and lighter)
f) Advantages: Easier to install, reduced hardware cost, BNC connectors widely
deployed 🡺 lower installation costs.
g) Disadvantages: Attenuation not as good, could not support as many stations
due to signal reflection caused by BNC Tee Connector.
IEEE 802.u 100Mb Fast Ethernet
•The basic idea was simple: keep all the old packet
formats, interface and procedural rules, just reduce the bit
time from 100 ns to 10 ns, to reach 100 Mbps.
•Coax cables are not used any more; in our old building in
2000 replaced by Cat5 UTP
•Cat 5 UTP: 2 pairs; 125 MHz, 4 bits encoded in 5 signals

100Base-T4 Cat 3 UTP 4 pairs 100 m cheap cat 3


100Base-TX Cat 5 UTP 2 pairs 100 m full duplex at 100 Mbps
100Base-F Fiber multi-mode 2000 m full duplex, long runs
Gigabit Ethernet Cat 5 UTP
Ethernet frame format

•Preamble of 7 bytes used to synchronize clocks.


•The Start Of Frame delimiter contains 10101011
•Addresses are 6 bytes.
•The addresses are unique in the world.
•The address containing all 1's is reserved for broadcast, a
message destinated to all recievers
•There were many variations in using the 2 byte length
•Most common now is to use it as a Type field, indicating that
the data is a higher level protocol packet, e.g. 0x0800 for IPv4
and 0x86DD for IPv6
The 802.11 Frame Structure

The data frame header contains 4 addresses, each in the standard 802
format. Two are used to identify the sending and receiving stations.
The other two are used for the source and destination of base
stations for intercell traffic.
The W bit indicates WEP (Wired Equivalent privacy)

•802.11b 2.4 GHz up to 11 Mb/s


•802.11a 5 GHz up to 54 Mb/s
•802.11g 2.4 GHz up to 54 Mb/s
•802.11n 5 GHz, up to 200 Mb/s
Interconnecting LANs
Q: Why not just one big LAN?
• Limited amount of supportable traffic: on single LAN, all
stations must share bandwidth
• limited length: 802.3 (Ethernet) specifies maximum cable
length
• large “collision domain” (can collide with many stations).

• Multiple LANs are connected through :


• HUB/Repeater :Connect two LANs at physical layer.
• Switch : Connect two LANs at the link layer(MAC address)
• Router : Connect two subnets at the network layer (IP address)
Interconnection Devices

• There are many different devices for interconnecting networks.


Hubs/Repeaters
• Physical Layer devices: essentially repeaters operating at
bit levels: repeat received bits on one interface to all other
interfaces
• Hubs can be arranged in a hierarchy (or multi-tier design),
with backbone hub at its top

Collison Domain
Hubs (more)
• Each connected LAN referred to as LAN segment
• Hubs do not isolate collision domains: node may collide
with any node residing at any segment in LAN
• Hub Advantages:
a) simple, inexpensive device
b) portions of the Multi-tier Hub LAN continue to operate if one hub
malfunctions
c) extends maximum distance between node pairs (100m per Hub)

• Hub Limitations:
•single collision domain results in no increase in max throughput
multi-tier throughput same as single segment throughput
•cannot connect different Ethernet types (e.g., 10BaseT and
100baseT)
Bridges
• Link Layer devices: operate on Ethernet frames, examining frame
header and selectively forwarding frame based on its destination.
• Bridge isolates collision domains since it buffers frames.
• When frame is to be forwarded on segment, bridge uses CSMA/CD
to access segment and transmit.

• Bridge advantages:
a) Isolates collision domains resulting in higher total max throughput, and does
not limit the number of nodes nor geographical coverage.
b) Can connect different type Ethernet since it is a store and forward device

Collison
Domain-2
Collison Domain-1 Collison Domain-3
Interconnection Without Backbone

• Not recommended for two reasons:


a) - single point of failure at Computer Science hub
b) - all traffic between EE and SE must path over CS segment

Switch
Hub
Switch ports
Twisted pair
Bridge Learning: example
Suppose C sends frame to D and D replies back with
frame to C

C 1

❑ C sends frame to bridge


a) bridge notes that C is on port 1 in the filtering table
b) bridge has no info about D, so floods to all the LANs
c) Nodes will compare the destination address of the frame
d) frame received by D
Bridge Learning: example

C 1
D 2
❑ D generates reply to C, sends
a) bridge sees frame from D
b) bridge notes that D is on interface 2
c) bridge knows C on interface 1, so selectively
forwards frame out via interface 1
Bridge Operation
bridge procedure(in_MAC, in_port,out_MAC)
Set filtering table (in_MAC) to in_port /*learning*/
lookup in filtering table (out_MAC) receive out_port
if (out_port not valid) /* no entry found for destination */
then flood; /* forward on all but the interface on
which the frame arrived*/

if (in_port = out_port) /*destination is on LAN on which


frame was received */
then drop the frame

Otherwise (out_port is valid) /*entry found for destination */


then forward the frame on interface indicate
S1
Self-learning multi-switch example Addres Port
s
C 1
Suppose C sends frame to I, I responds to C
I 4

1 S4
S1 3 S4
1 1 S3
A 4 S2 2 Addres Port
F s
1 D I
B C C 1
E G H
I 3
S3
▪ Q: show switch tables and packet forwarding in S1, S2, S3, S4 Addres Port
s
C 1
S2 I 2
Addres Port
s
C 1
The Danger of Loops
CC DD
a) <Src=AA, Dest=DD>
b) This continues to infinity
a) How do we stop this?
c) Remove loops from the Hub
topology
a) Without physically unplugging cables Port 2 Port 2
AA 2
1 AA 2
1
d) 802.1 uses an algorithm to Port 1 Port 1
build and maintain a
spanning tree for routing Hub

AA BB
Loops and Switching

N S6
P

S5 O
K
L M S1
S2 S4
A S3
F I
B C D
E G H

There should be only one path exist from the Source to Destination to avoid the
loops at the data link layer.
Spanning Tree Definition

a) A subset of edges in a graph that:


a) Span all nodes
b) Do not create any cycles
b) This structure is a tree 5

1 2 3 4 6 2

5 3
4 1

6 7 7
802.1 Spanning Tree Approach
• Elect a bridge to be the root of the tree
• Every bridge finds shortest path to the root
• Union of these paths becomes the spanning tree

• Bridges exchange Configuration Bridge Protocol Data


Units (BPDUs) to build the tree
a) Used to elect the root bridge
b) Calculate shortest paths
c) Locate the next hop closest to the root, and its port
d) Select ports to be included in the spanning trees
Definitions
• Bridge ID (BID) = <Random Number>
• Root ID: bridge with the lowest BID in the tree.
• Path Cost: cost (in hops) from a transmitting bridge to
the root
• Each port on a bridge has a unique Port ID.
• Root Port: port that forwards to the root on each bridge
• Designated Bridge: the bridge on a LAN that provides
the minimal cost path to the root
a) The designated bridge on each LAN is unique
Initial State
<designated Bridge ID: Root Path Cost/ Root ID>
I am root

<A:A/0> <A:A/0>
<B:B/0> <C:C/0>
I am root I am root

<C:C/0>

<B:C/0>
B C
Determining the Root

• Initially, all hosts assume they are the root.


• Bridges broadcast BPDUs:
Designated Bridge ID Root path cost Root ID

• Based on received BPDUs, each switch chooses:


a) A new root (smallest known Root ID)
b) A new root port (what interface goes towards the root)
c) A new designated bridge (who is the next hop to root)
Comparing BPDUs
BPDU1 BPDU2
B1:R1/Cost1 B2:R2/Cost2

if R1 < R2: use BPDU1


else if R1 == R2 and Cost1 < Cost2: use BPDU1
else if R1 == R2 and Cost1 == Cost 2 and B1 < B2: use
BPDU1
else: use BPDU2
Root Bridge Recognized
<Root ID, Root Path Cost, designated Bridge ID>
I am root

<B :A >
/1>
C : A/1
<

<C:A/1>

<B:A/1>
B C

I am I am
designated designated
Designated Bridge
Recognized
<Root ID, Root Path Cost, Designated Bridge ID>
I am root

<A:A/0> <A:A/0>

<B:A/1>
B C

I am
designated
Ports Disabled
<Root ID, Root Path Cost, Designated Bridge ID>
I am root

<A:A/0> <A:A/0>

<B:A/1>
B C

I am
designated
Spanning Tree Construction

0: 0/0 12:
12:12/0
0/1 3: 0/2
3/0

27: 27/0
27: 0/1 41: 41/0
41: 3/1
0/2

3/2
9: 0/3
9/0 68: 68/0
68: 3/2
9/1
0/3
Application
Transport
Network
Link
Physical

Computer Networks
Network Layer

Dr. Subhrendu Chattopadhyay


Department of CSE
SRM University-AP
Overview
application
transport
network
• Functions: data link
physical
network
data link
network physical network
a) Routing issues data link data link
physical physical
a) determine “good” path network
data link
(sequence of routers) thru physical
network
data link
network from source to dest. physical

– Congestion (Not Contention!) network


network
data link
data link
• More packets enter an physical
physical
network
area than can be processed data link
physical
– Internetworking
application
• connecting different transport
network
data link
network technologies together physical

• Network layer protocols in every host, router


Network Layer Design Issues
• Services Provided to the Transport Layer
a) The network layer should shield the transport layer from having to know
details of the underlying subnet

• Network Layer Services can:


a) Connection-Oriented: Provides Virtual Circuit (VC) subnet,
a) source-to-destination path behaves much like telephone circuit, Avoids
choosing a new route for each packet.
b) A virtual circuit remembers how to send a packet from source to destination.

b) Connection-less: Provides Datagram subnet,


a) Each packet sent is routed independently of its predecessors
Connectionless: Datagram (1)
• No call setup at network layer
• Packets forwarded using destination host address
a) packets between same source-dest. pair may take different paths
• Use in Internet

2. Receive Data application


transport
network
data link
physical

application 1. Send Data


transport
network
data link
physical
Connectionless: Datagram (2)
Store-and-Forward packet
Subnet

The table of router A is


changed because of some
Routing tables reasons!

Management and update


this tables for routing =
Routing algorithm
a) Routing within a diagram subnet:
Virtual Circuits (1)
• Call setup, do for each call before data can flow
• Each packet carries VC identifier
• Used in ATM, frame-relay, X.25

6. Receive data
3. Accept call application
transport
2. Incoming call network
data link
5. Data flow begins physical
4. Call connected
application 1. Initiate call
transport
network
data link
physical
Comparison of Virtual-Circuit and Datagram
Internet ATM
Quality of Service: QoS

• Factors:
a) Timing
a) Connection Establishment Delay
b) End-To-End Delay
b) Connection Establishment Failure Probability
c) Throughput or Bandwidth Guarantee
d) Ordering Preservation
e) Congestion Control
f) Bit-Error rate or Packet-Loss Rate Control
g) Protection
h) Priority
i) …
Application
Transport
Network
Link
Physical

Computer Networks
Network Layer: Routing

Dr. Subhrendu Chattopadhyay


Department of CSE
SRM University-AP
Routing (1)
• The network layer is responsible for routing packets from the source to
destination.
• The routing algorithm is the piece of software that decides where a
packet goes next (e.g., which output line, or which node on a
broadcast channel).

• For connectionless networks, the routing decision is made for each


datagram. For connection-oriented networks, the decision is made
once, at circuit setup time.

• The routing algorithm must deal with the following issues:


a) Correctness, simplicity, stability, fairness and optimality
b) Mimizing mean packet delay or maximizing total network throughput

• Routing is different from Forwarding!:


a) Forwarding: Select the output path using routing table
b) Routing: Management and updating the routing tables
Routing (2)
• There are two types:
a) Static (Non-Adaptive)
a) routes never update or update slowly over time
b) Examples: Dijkstra, Flooding algorithm

b) Dynamic (Adaptive)
a) routes update more quickly use dynamic information of current topology such as
load, delay, …
b) Examples: Distance Vector, Link State Routing
Single-Source Shortest Path Problem
Dijkstra Algorithm
Single-Source Shortest Path Problem - The problem of
finding shortest paths from a source vertex v to all other vertices
in the graph.
Applications
- Maps (Map Quest, Google Maps)
- Routing Systems
Dijkstra's algorithm
Dijkstra's algorithm - is a solution to the single-source
shortest path problem in graph theory.

Works on both directed and undirected graphs. However,


all edges must have nonnegative weights.

Input: Weighted graph G={E,V} and source vertex v∈V,


such that all edge weights are nonnegative

Output: Lengths of shortest paths (or the shortest paths


themselves) from a given source vertex v∈V to all other
vertices
Approach
a) The algorithm computes for each vertex u the distance to u
from the start vertex v, that is, the weight of a shortest path
between v and u.
b) the algorithm keeps track of the set of vertices for which the
distance has been computed.
c) Every vertex has a label D associated with it. For any vertex
u, D[u] stores an approximation of the distance between v
and u. The algorithm will update a D[u] value when it finds a
shorter path from v to u.
Dijkstra’s algorithm

2
Start with G
3
5 F C K dv pv
10
A 7 3 A
8 4
18 B
4
B D
9 C
10
H
2 9 25 D
3
G E E
7
F
G T 0 −
H
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A
8 4
18 B
4
B D
9 C
10
H
2 9 25 D 2 G
3
G E E
7
F
G T 0 −
H 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A
8 4
18 B
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E
G E
7
F
G T 0 −
H 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A
8 4
18 B
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7
F 20 D
G T 0 −
H 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A
8 4
18 B
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7
F 20 D
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A 7 H
8 4
18 B 12 H
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7
F 20 D
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B 12 H
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7
F 20 D
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B 12 H
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7
F 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B T 12 H
4
B D
9 C
10
H
2 9 25 D T 2 G
3 E 27 D
G E
7 F 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B T 12 H
4
B D
9 C 16 B
10
H
2 9 25 D T 2 G
3 E 22 B
G E
7 F 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B T 12 H
4
B D
9 C T 16 B
10
H D T 2 G
2 9 25
3 E 22 B
G E
7 F 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B T 12 H
4
B D
9 C T 16 B
10
H D T 2 G
2 9 25
3 E 22 B
G E
7 F 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 3 A T 7 H
8 4
18 B T 12 H
4
B D
9 C T 16 B
10
H D T 2 G
2 9 25
3 E 22 B
G E
7 F T 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Update unselected nodes
3
5 F C K dv pv
10
A 7 A T 7 H
8 4
18 B T 12 H
4
B D
9 C T 16 B
10
H D T 2 G
2 9 25
3 E 19 F
G E
7 F T 17 A
G T 0 −
H T 3 G
Dijkstra’s algorithm

2
Select minimum distance
3
5 F C K dv pv
10
A 7 A T 7 H
8 4
18 B T 12 H
4
B D
9 C T 16 B
10
H D T 2 G
2 9 25
3 E T 19 F
G E
7 F T 17 A
G T 0 −
H T 3 G

Done
Dijkstra’s algorithm

2
Select minimum distance
F C Dest(G) Via dv
10
A A (G,H) 7
4
4 B (G,H) 12
B D
9
C (G,H) 16
H
2 D (G,D) 2
3
G E E (G,F) 19
F (G,H) 17
H (G,H) 3

Final Path
Dijkstra’s-Example

Distance(source) = 0 0 ∞ Distance (all vertices


A
2
B to source) = ∞

4 1 3 10

2 2 ∞
∞ C D E

5 8 ∞ 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance.


Distance Vector Routing

Distance to Node
Info at
B 1 C B C D E
node A
7
A 0 7 ∞ ∞ 1
A 8 2 B 7 0 1 ∞ 8
C ∞ 1 0 2 ∞
1
E 2 D D ∞ ∞ 2 0 2
E 1 8 ∞ 2 0
Distance Vector Routing
D sends vector to E
Iʼm 2 from C, 0
from D and 2 from
E
Distance to Node
Info at
B 1 C B C D E
node A
7
A 0 7 ∞ ∞ 1
A 8 2 B 7 0 1 ∞ 8
C
∞ 1 0 2 ∞
1
D
E 2 D ∞ ∞ 2 0 2
E
1 8 4 2 0
D is 2 away, 2+2< ∞,
so best path to C is 4
Distance Vector Routing
B sends vector to A
Iʼm 7 from A, 0
from B, 1 from C &
8 from E
Distance to Node
Info at
B 1 C B C D E
node A
7
A 0 7 8 ∞ 1
A 8 2 B 7 0 1 ∞ 8
C
∞ 1 0 2 ∞
1
D
E 2 D ∞ ∞ 2 0 2
E
B is 7 away, 1+7< ∞ so 1 8 4 2 0
best path to C is 8
Distance Vector Routing
E sends vector to A
E is 1 away, 4+1<8
so C is 5 away, 1+2<
∞ so D is 3 away
Distance to Node
Info at
B 1 C B C D E
node A
7
A 0 7 5 3 1
A 8 2 B 7 0 1 ∞ 8
C
∞ 1 0 2 ∞
1
D
E 2 D ∞ ∞ 2 0 2
E
1 8 4 2 0
Iʼm 1 from A, 8 from B, 4
from C, 2 from D & 0 from E
Distance Vector Routing
…until Convergence

Distance To Node
Info at
B 1 C B C D E
node A
7
A 0 6 5 3 1
A 8 2 B 6 0 1 3 5
C
5 1 0 2 4
1
2 D
E D 3 3 2 0 2
E
1 5 4 2 0
Distance Vector Routing

Node B’s distance vectors

Next hop
Dest A E C
B 1 C
7 A 6
C 1
A 2
8 D 3
E 5
1
E 2 D
Distance Vector Routing
Handling Link Failure
• A marks distance to E as ∞ , and tells B
• E marks distance to A as ∞ , and tells B and D
• B and D recompute routes and tell C, E and E
• etc… until converge
Info at Distance to Node
B 1 C
node
A B C D E
7

A 8 2
A 0 7 8 10 12
B
7 0 1 3 5
1 C
E 2 D 8 1 0 2 4
D
10 3 2 0 2
E 12 5 4 2 0
Distance Vector Routing-Example

Distance(source) = 0 0 ∞ Distance (all vertices


A
2
B to source) = ∞

4 1 3 10

2 2 ∞
∞ C D E

5 8 ∞ 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance.


Distance Vector Routing

Distance Vector Routing


a) Each node knows the distance (=cost) to its directly connected neighbors
b) A node sends a list to its neighbors with the current distances to all nodes
c) Idea:
d) Tell neighbors about learned distances to all destinations
e) If all nodes update their distances, the routing tables eventually converge
Distance Vector vs. Link State Routing
• With distance vector routing, each node has information only
about the next hop:
a) Node A: to reach F go to B
b) Node B: to reach F go to D
c) Node D: to reach F go to E
d) Node E: go directly to F
A B C

• Distance vector routing makes


poor routing decisions if
directions are not completely
correct
D E F
(e.g., because a node is down).

• If parts of the directions incorrect, the routing may be incorrect until the
routing algorithms has re-converged.
Distance Vector vs. Link State Routing
• In link state routing, each node has a complete map of the
topology (Link state information must be flooded to all nodes).

• If a node fails, each


A B C A B C A B C

node can calculate D E F D E F D E F

the new route. A B C


• Guaranteed to converge

• Difficulty: All nodes need to


have a consistent view of the D E F
network A B C
A B C A B C

D E F
D E F D E F
Link State Routing
• Each router creates a link state packet (LSP) which
contains names (e.g. network addresses) and cost to
each of its neighbours

a) The LSP is transmitted to all other routers, who each update their
own records.

b) When a routers receives LSPs from all routers, it can use


(collectively) that information to make topology-level decisions
Link State Packets
• LSPs are generated and distributed when:
a) A time period passes(proactive routing)
b) New neighbours connect to the router
c) The link cost of a neighbour has changed
d) A link to a neighbour has failed (link failure)
e) A neighbour has failed (node failure)

• Distribution of LSPs can be difficult


a) Routers themselves are the means for delivering messages
b) How do routers deliver their own messages, particularly when routers are in
an inconsistent state
a) e.g. During link failure, before each router has been notified
of the problem
Link State Packets
• One method for LSP distribution: Flooding
a) Each LSP received is transmitted to every direct neighbour
(except the neighbour where the LSP came from)
b) This creates an exponential number of packets on the network.
c) It does, however, guarantee that the LSP will be received by
every router
a) Disadvantage of flooding:
b) Possibility of count-to-infinity (Infinite Loops)
c) Routers may receive the same LSP from multiple routers
Link State Packets
• An improvement to the flooding is as follows:
• When an LSP is received, it’s sequence number is
compared with the stored copy
a) If it is identical to the stored copy, it is dropped
b) If it is different, the stored LSP is overwritten with the new LSP
and the LSP is transmitted to every direct neighbour (except the
source of the LSP)
• This scheme works because if a given router has
already received a LSP from another neighbour, it
will have also already distributed the LSP to all of its
neighbours
Link State Routing Algorithm

• Ok, now that we know how to distribute LSPs, how are they
used to determine routes?

a) The algorithm used was developed by Dijkstra.

b) Essentially, the algorithm runs at each router, computing each possible path to
the destination, adding up each cost

a) The path with the lowest cost is used


Operation of a Link State Routing protocol

Dijkstra’s
Received Link State Algorithm IP Routing
LSAs Database Table

LSAs are flooded


to other interfaces
Dijkstra’s LSR Algorithm
a) Consider the following network:

6 2
A B C 5
2 1 2 G
2 4
D E F 1

Link state database:


A B C D E F G
B 6 A 6 B 6 A 2 B 1 C 2 C 5
D 2 C 2 F 2 E 2 D 2 E 4 F 1
E 1 G 5 F 4 G 1
Dijkstra’s LSR Algorithm
a) Now, if we want to generate a PATH for
C:
a) First, we add (C,0,0) to PATH

C (0)
Dijkstra’s LSR Algorithm
a) Examine C’s LSP
a) Add F, G, and B to TENT

C (0)

(2) F G (5) B (2)


Dijkstra’s LSR Algorithm
a) Place F in PATH (shown as solid line)
a) Add G and E to TENT (adding costs)

C (0)

(2) F G (5) B (2)

(3) G (6)
E
Dijkstra’s LSR Algorithm
a) G exists in TENT twice, keep only the
best
a) The new G is a better path than the old (3 < 5)

C (0)

(2) F G (5) B (2)

(3) G (6)
E
Dijkstra’s LSR Algorithm
a) Put B into path (shown as solid line)
a) Add A and E to TENT

C (0)

(2) F B (2)

(3) G (6) (3) A (8)


E E
Dijkstra’s LSR Algorithm
a) E exists in TENT twice, keep only the
best
a) The new E is better than the old (3 < 6)

C (0)

(2) F B (2)

(3) G (6) (3) A (8)


E E
Dijkstra’s LSR Algorithm
a) Place E in PATH (shown as solid line)
a) Add D to TENT

C (0)

(2) F B (2)

(3) G (3) A (8)


E

(5)
D
Dijkstra’s LSR Algorithm
a) Place G in PATH (shown as solid line)
a) All G’s LSP elements already exist in TENT

C (0)

(2) F B (2)

(3) G (3) A (8)


E

(5)
D
Dijkstra’s LSR Algorithm
a) Place D in PATH (shown as solid line)
a) Add path to A since it is better than old A

C (0)

(2) F B (2)

(3) G (3) A (8)


E

(5)
D

A (7)
Dijkstra’s LSR Algorithm
a) Place A in PATH (shown as solid line)
a) All A’s LSP elements already exist in PATH

C (0)

(2) F B (2)

(3) G (3)
E

(5)
D

A (7)
Dijkstra’s LSR Algorithm
a) We are done since all routes from TENT
were placed into PATH

C (0)

(2) F B (2)

(3) G (3)
E

(5)
D

A (7)
Dijkstra’s LSR Algorithm
• We can now create a forwarding database:

Forwarding Database
C (0) Destination Port

(2) F C C
B (2)
F F
(3) G (3) G F
E
B B
(5) E B
D
D B
A (7) A B
Wireless Networks
• Two types of wireless networks:
a) infrastructured network:
a) base stations are the bridges
b) a mobile host will communicate with the nearest base station
c) handoff is taken when a host roams from one base to another
b) ad hoc network:
a) infrastructureless: no fixed base stations
b) without the assistance of base stations for communication
c) Due to transmission range constraint,
a) two MHs need multi-hop routing for communication
d) quickly and unpredictably changing topology
MANET
• MANET = Mobile Ad Hoc Networks
a) a set of mobile hosts, each with a transceiver
b) no base stations; no fixed network infrastructure
c) multi-hop communication
d) needs a routing protocol which can handle changing topology
Applications of MANET
• battlefields

• nature disaster areas

• fleet in oceans

• historical cites

• festival ground
On-demand vs. Table-driven

❑ Table-Driven Routing Protocol:


a) proactive!!
b) continuously evaluate the routes
c) attempt to maintain consistent, up-to-date routing
information
a) when a route is needed, one may be ready immediately
d) when the network topology changes
a) the protocol responds by propagating updates throughout the
network to maintain a consistent view
• Source-Initiated On-Demand Routing Protocol:
a) reactive!!
b) on-demand style: create routes only when it is desired by the source node
a) route discovery: invoke a route-determination procedure
b) the procedure is terminated when
a) a route has been found
b) no route is found after all route permutations are examined
c) longer delay: sometimes a route may not be ready for use immediately when
data packets come
AODV Concepts
• Pure on-demand routing protocol
a) A node does not perform route discovery or maintenance until it needs a route
to another node or it offers its services as an intermediate node
b) Nodes that are not on active paths do not maintain routing information and do
not participate in routing table exchanges.
c) Routes are based on dynamic table entries maintained at intermediate nodes
RREQ-Path discovery (1/5)
• Initiated, when node needs to communicate with
new node (no routing information in table)
• Route Request (RREQ) packet is broadcasted to
network
• An expanding ring search should be used
a) TTL (Time to live) parameter in IP-header sets the lifetime in
hops for packets
b) TTL is first small and is then increased, if a route is not
found until a limit is reached

64 bits
hop_cn
ctrl_info broadcast_id (RREQ_id)
RREQ

t
dest_addr dest_seq_num 192
source_addr source_seq_num bits
Path discovery (2/5)

• Example: Node A
A needs to communicate
RREQ
with F
RREQ B
• RREQ A->F is
C
released to network
D
• Neighbors C and B
receive RREQ and
E F
learn route to A
Path discovery (3/5)
• Intermediate nodes C
and B do not have
route to F
A • RREQ is broadcasted
forward with increased
B hop count only if hop
C limit is not yet reached
• A receives it’s own
D RREQ
a) paths to B and C are
formed
F b) RREQ is discarded
E • Intermediate node D
receives multiple
copies of RREQ form A
a) Direct routes to C and B
are formed
b) The first arrived RREQ is
set used to form route to A
(e.g. B here)
Path discovery (4/5)
• D forwards RREQ
A • B and C discard
duplicate RREQ and
B learn route to D
C • Destination node F
D finally gets RREQ

F
E
RREP-Path discovery (5/5)
• Route reply packet (RREP) is
sent back to node A along
A reverse route
a) In fact any node, which has a
RREP fresh route to destination can
B send RREP and therefore end
route search
C RREP • Active forward path from A to
F is created
D a) Intermediate nodes also have
now active forward path to F
RREP • Route is ready for data
transmission
E F

64 bits
hop_cn
ctrl_info
RREP

t
dest_addr dest_seq_num 160
source_addr lifetime bits
Routing tables

A
B
C
D

E F

❑ Route expiration times are updated when route is used


❑ Routes in AODV are in fact virtual routes!
a) a single node do not know the complete route and therefore
“route control” is distributed
Path maintenance (original AODV)
a) Example: Link D<->F is
broken due to movement of
A F
RREP (lost node)
B b) A special RREP(Route
Error-RERR) is send
C RREP (lost node)
upstream in path
RREP (lost node)
D (now B->A)
a) hop_count to lost destination
RREP (lost node)
lost link (now F) is set to ∞
E F c) From RREP node A sees a
broken link towards F
a) New route is searched as in initial
route search (RREQ)
F if needed
Dynamic Source Routing (DSR) -
Introduction
• Reactive or On Demand Developed at CMU in 1996
• Route discovery cycle used for route finding – on Demand
• Utilizes source routing (entire route is part of the header)
• When node S wants to send a packet to node D, but does
not know a route to D, node S initiates a route discovery
• Source node S floods Route Request (RREQ)
• Each RREQ, has sender’s address, destination’s address,
and a unique Request ID determined by the sender
• Each node appends own identifier when forwarding RREQ
DSR – Route Discovery

B
RREQ:S
S A
C D

1. Node S needs a route to D


2. Broadcasts RREQ packet
DSR – Route Discovery

B
RREQ:S
S A
C D

1. Node S needs a route to D


2. Broadcasts RREQ packet
3. Node A receives packet, has no route to D
Rebroadcasts packet after adding its address to source
route
Route Discovery – Node Actions

Upon receiving a RREQ, the node takes


the following actions:
1. if the node is the Target (Destination)
Returns a Route Reply (RREP) message to the
sender
Copies the accumulated route record from
RREQ into RREP
Sender upon receiving RREP, caches the route
in its route cache for subsequent routing
DSR – Route Discovery

B
RREQ:S, A
S A
RRE C D
Q:S
,A
1. Node S needs a route to D
2. Broadcasts RREQ packet
3. Node A receives packet, has no route to D
Rebroadcasts packet after adding its address to source
route
DSR – Route Discovery

B
RREQ: S, A

S A RREQ: S, A
C D
4. Node C receives RREQ, has no route to D
Rebroadcasts packet after adding its address to source
route
DSR – Route Discovery

RREQ: S, A, C
S A
C D
4. Node C receives RREQ, has no route to D
Rebroadcasts packet after adding its address to source
route
DSR – Route Discovery

RREQ: S, A, C
S A
C D
4. Node C receives RREQ, has no route to D
Rebroadcasts packet after adding its address to source
route
5. Node D receives RREQ, unicasts RREP to C
D puts entire route in RREP message
Route Discovery in DSR
Y

Z
S E
F
B
C M L
J
A G
H D
K
I N

Represents a node that has received RREQ for D from


S
Route Discovery in DSR
Y
Broadcast transmission

[S] Z
S E
F
B
C M L
J
A G
H D
K
I N

Represents transmission of RREQ

[X,Y] Represents list of identifiers appended to RREQ


Route Discovery in DSR
Y

Z
S [S,E]
E
F
B
C M L
J
A [S,C] G
H D
K
I N

❑ Node H receives packet RREQ from two neighbors:


potential for collision
Route Discovery in DSR
Y

Z
S E
F [S,E,F]
B
C M L
J
A G
H D
[S,C,G] K
I N

❑ Node C receives RREQ from G and H, but does not forward


it again, because node C has already forwarded RREQ once
Route Discovery in DSR
Y

Z
S E
F [S,E,F,J]
B
C M L
J
A G
H D
K
I [S,C,G,K] N

❑ Nodes J and K both broadcast RREQ to node D


Route Discovery in DSR
Y

Z
S E
[S,E,F,J,M]
F
B
C M L
J
A G
H D
K
I N

❑ Node D does not forward RREQ, because node D


is the intended target of the route discovery
Route Reply in DSR
Y

Z
S RREP [D,J,F, E,S]
E
F
B
C M L
J
A G
H D
K
I N

Represents RREP control message


Dynamic Source Routing (DSR)
Node S on receiving RREP, caches the
route included in the RREP

When node S sends a data packet to D, the


entire route is included in the packet
header
hence the name source routing

Intermediate nodes use the source route


included in a packet to determine to whom
a packet should be forwarded
5-31
Data Delivery in DSR
Y

DATA [S,E,F,J,D]
Z
S E

F
B
C M L
J
A G
H D
K
I N

❑ Packet header size grows with route length


IP Addressing
IP Addresses
What is an IP Address?

• An IP address is a unique global address for a network


interface

• An IP address:
- is a 32 bit long identifier
- encodes a network number (network prefix)
and a host number
Dotted Decimal Notation

• IP addresses are written in a so-called dotted decimal


notation
• Each byte is identified by a decimal number in the range
[0..255]:

• Example:
10000000 10001111 10001001 10010000
1st Byte 2nd Byte 3rd Byte 4th Byte
= 128 = 143 = 137 = 144

128.143.137.144
Network prefix and Host number

• The network prefix identifies a network and the host number


identifies a specific host (actually, interface on the network).

network prefix host number

• How do we know how long the network prefix is?


– The network prefix used to be implicitly defined
• class-based addressing, A,B,C,D
– The network prefix now is flexible and is indicated by
• prefix/netmask (classless Interdomain routing)-CIDR
The old way: Classful IP Adresses

• When Internet addresses were standardized (early 1980s),


the Internet address space was divided up into classes:
– Class A: Network prefix is 8 bits long
– Class B: Network prefix is 16 bits long
– Class C: Network prefix is 24 bits long

• Each IP address contained a key which identifies the class:


– Class A: IP address starts with “0”
– Class B: IP address starts with “10”
– Class C: IP address starts with “110”
The old way: Internet Address Classes
The old way: Internet Address Classes
Example

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
Example

Example: www.google.com
•IP address is 128.143.137.144
– Is that enough info to route datagram??? -> No, need netmask or
prefix at every IP device (host and router)
•Using Prefix notation IP address is: 128.143.137.144/16
– Network prefix is 16 bits long

•Network mask is: 255.255.0.0 or hex format: ffff0000


-----> Network id (IP address AND Netmask) is: 128.143.0.0
-----> Host number (IP address AND inverse of Netmask) is: 137.144

128.143 137.144
Problems with Classful IP Addresses

• The original classful address scheme had a number of problems


• In classful addressing, a large part of the available addresses were
wasted.
Problem 1. Inflexible. Assume a company requires 2,000 addresses
– Class A and B addresses are overkill
– Class C address is insufficient (requires 8 Class C addresses)

Alternate is: Subnetting


Subnetting

• Problem: Organizations
have multiple networks
University Network
which are independently
managed Engineeri
ng Medical
– Solution 1: Allocate an School
address for each network School
• Difficult to manage
• From the outside of the Library
organization, each
network must be
addressable ie have an
identifiable address.
– Solution 2: Add another
level of hierarchy to the
IP addressing structure Subnetting
Basic Idea of Subnetting

• Split the host number portion of an IP address into a


subnet number and a (smaller) host number.
• Result is a 3-layer hierarchy

network prefix host number

subnet
network prefix number
host number

extended network prefix


• Then:
• Subnets can be freely assigned within the organization
• Internally, subnets are treated as separate networks
• Subnet structure is not visible outside the organization
Subnet Masks

• Routers and hosts use an extended network prefix (subnet


mask) to identify the start of the host numbers

* There are different ways of subnetting. Commonly used netmasks for university
networks with /16 prefix (Class B) are 255.255.255.0 and 255.255.0.0
Example of a Subnetting Plan

Subnet 128.49.0.0/24
Internet
Subnet 1

Subnet 128.49.1.0/24
Subnet 3
Router
R
Subnet 128.49.2.128/24
Subnet 4

Subnet 2
Subnet 128.49.3.0/24
Advantages of Subnetting

• With subnetting, IP addresses use a 3-layer hierarchy:


» Network
» Subnet
» Host
• Improves efficiency of IP addresses by not consuming an
entire address space for each physical network.
• Reduces router complexity. Since external routers do not
know about subnetting, the complexity of routing tables at
external routers is reduced.

• Note: Length of the subnet mask need not be identical at all


subnetworks.
Subnetting Example
Network without subnets

128.143.0.0/16
Same Network with Subnets
Same network with different subnetmasks

128.143.137.0
Subnet
Subnetting Example

• An organization with 4 departements has the following IP


address space: 10.2.22.0/23. As the systems manager, you
are required to create subnets to accommodate the IT needs
of 4 departments. The subnets have to support to 200, 61, 55,
and 41 hosts respectively. What are the 4 subnet network
numbers?

• Solution:
– 10.2.22.0/24 (256 addresses > 200)
– 10.2.23.0/26 (64 addresses >61)
– 10.2.23.64/26 (64 addresses > 55)
– 10.2.23.128/26 (64 addresses > 41)
CONGESTION CONTROL

1
Congestion Control
• When routers are receiving packets faster than
they can forward them, one of two things must
happen:
– The subnet must prevent additional packets from
entering the congested region until those already
present can be processed.
– The congested routers can discard queued packets to
make room for those that are arriving.

– When one part of the subnet (e.g. one or more


routers in an area) becomes overloaded,
congestion results.
2
Factors that Cause Congestion
• Packet arrival rate exceeds the outgoing link
capacity.
• Insufficient memory to store arriving
packets
• Bursty traffic
• Slow processor

3
Congestion Control vs Flow
Control
• Congestion control is a global issue –
involves every router and host within the
subnet
• Flow control – scope is point-to-point;
involves just sender and receiver.

4
Congestion Control, cont.
• Congestion Control is concerned with efficiently
using a network at high load.
• Several techniques can be employed. These include:
– Warning bit
– Choke packets
– Load shedding
– Random Early Detection (RED)
• The first 3 deal with congestion detection and
recovery. The last one deal with the congestion
avoidance.

5
Warning Bit
• A special bit in the packet header is set by the
router to warn the source when congestion is
detected.
• The bit is copied and piggy-backed on the ACK
and sent to the sender.
• Algorithm at source
• The sender monitors the number of ACK packets
it receives with the warning bit set and adjusts its
transmission rate accordingly.
• As long as warning bits arrive: reduce traffic
• Less warning bits: increase traffic 6
Choke Packets
• A more direct way of telling the source to slow
down.
• A choke packet is a control packet generated at a
congested node and transmitted to restrict traffic
flow.
• The source, on receiving the choke packet must
reduce its transmission rate by a certain percentage.

• An example of a choke packet is the ICMP Source


Quench Packet.
7
Source based
Choke packets

• Choke packets:
– Example showing slow
reaction
– Solution: Hop-by-Hop choke
packets

8
Hop-by-Hop Choke Packets
• Over long distances or at high speeds choke
packets are not very effective.
• A more efficient method is to send to choke
packets hop-by-hop.
• This requires each hop to reduce its
transmission even before the choke packet
arrive at the source.

9
Hop-by-hop
choke packets
• Hop-by-Hop choke packets
– Have choke packet take
effect at every hop
– Problem: more buffers
needed in routers

10
Load Shedding
• When buffers become full, routers simply discard
packets.
• Which packet is chosen to be the victim depends
on the application and on the error strategy used in
the data link layer.
• For a file transfer, for, e.g. it cannot discard older
packets since this will cause a gap in the received
data.
• For real-time voice or video it is probably better to
throw away old data and keep new packets.

11
Random Early Discard (RED)
• This is a proactive approach in which the
router discards one or more packets before
the buffer becomes completely full.
• Each time a packet arrives, the RED
algorithm computes the average queue
length, avg.
• If avg is lower than some lower threshold,
congestion is assumed to be minimal or
non-existent and the packet is queued.

12
RED, cont.
• If avg is greater than some upper threshold,
congestion is assumed to be serious and the
packet is discarded.
• If avg is between the two thresholds, this
might indicate the onset of congestion. The
probability of congestion is then calculated.

13
Application Layer

Dr. Satish Anamalamudi,


Department of CSE
SRM University-AP
Applications Layer – allows user to interface with the network
through process
Processes communicating
host or host or
server server
Process:
program running within a host controlled by
app developer
process process
Client process: socke socke
t t
initiates communication TCP with TCP with
buffers, Internet buffers,
Server process: variables variables
waits to be contacted
Controlled by OS

process sends/receives messages to/from its socket

identifier includes both IP address and port numbers


associated with process on host.
App-layer protocol defines
• Types of messages exchanged,
– e.g., request, response
• Message syntax:
– what fields in messages & how fields are defined
• Message semantics
– meaning of information in fields
• Rules for when and how processes send & respond to
messages
Public-domain protocols: Proprietary protocols:
♦ defined in RFCs ♦ Owned by individuals
♦ allows for interoperability
♦ e.g., HTTP, SMTP
Transport service requirements of common apps

Application Data loss Throughput Time Sensitive

file transfer no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5kbps-1Mbps yes, 100’s msec
video:10kbps-5Mbps
stored audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant few kbps up yes, 100’s msec
instant messaging no loss elastic no
Internet transport protocols services
TCP service:
• connection-oriented: setup required between client and server
processes
• reliable transport between sending and receiving process
• flow control: sender won’t overwhelm receiver
• congestion control: Limit sender when network overloaded
• does not provide: timing, minimum throughput guarantees, security
UDP service:
• unreliable data transfer between sending and receiving process
• does not provide: connection setup, reliability, flow control,
congestion control, timing, throughput guarantee, or security
Application Protocols
• HTTP – Used to transfer data between clients/servers
using a web browser
• DNS – Matches domain names with IP addresses
• SMTP– used to send email messages from clients to
servers over the internet
• FTP – allows the download/upload of files between a
client/server
• Telnet – allows users to login to a host from a remote
location and take control as if they were sitting at the
machine (virtual connection)
HTTP overview
r Web page consists of base HTML-file
which includes several referenced
objects
r Each object is addressable by a URL
HT HTTP: hypertext transfer protocol
TP
req
PC running HT ues
t
r Web’s application layer protocol
TP
Explorer res
pon
r Request-response protocol
se r client/server model
❖ client: browser that requests,
t
ues receives, “displays” Web objects
e q
T Pr o nse Server ❖ server: Web server sends objects in
HT s p running
P re response to requests
T T Apache Web
H
server r uses TCP
r Protocol for transfer of various data formats in
between server and client
Mac running
Eg : Plaintext, Hypertext, Images, Video
Navigator
r HTTP does not handle network connectivity or
how information is transmitted
---TCP/IP does this
WWW Service and HTTP
• Steps:
– 1) URL is typed in the address bar.
2) Browser checks with DNS server to convert it to an IP
address
3) Connects to the server requested
4) Using HTTP or HTTPS protocol requirements, the browser
sends a GET request to the server to ask for the desired
html document (usually index.html)
5) The server sends the HTML code for the web page to the
browser.
6) The browser interprets the HTML code and formats the
page to fit the browser window.
7) See the next slide for an example.
WWW Service and HTTP

HTTP/HTTPS are some of the


MOST used application protocols!
URL – Uniform Resource Locator
• an URL identifies a resource in the WWW
• URLs are a subset of URIs (Uniform Resource Identifiers);
URL=URI that provides the location for a resource
• general form of a URL:
• <scheme> : //<host> :<port> /<path>
– scheme
• The protocol you are using
– host
• Host name or IP number
– port
• TCP port number that protocol server is using
– path
• Path and filename reference of object on server
Communication
• Server tells to the client about what type of
information is coming before information
arrives
– File extensions
• .html
• .txt
• .ps
• .gif .tiff .jpeg
• .mpeg
• .vrml

HTTP 12
HTTP 1.0
• HTTP request
– Method
– URI
– Protocol version
– Optional other information

HTTP 13
HTTP 1.0
• Method
– Get
• Request content from the server
– Head
• Returns information about object
– Post
• Sends information to be stored on server or as
input to script

HTTP 14
HTTP 1.0
• HTTP response
– Status line
• Status-codes 2xx - Success
– The action was successfully received, understood, and
accepted
» 200 OK
» 201 POST command successful
» 202 Request accepted
» 203 GET or HEAD request fulfilled
» 204 No content

HTTP 15
HTTP 1.0
• HTTP response
– Status line
• Status-codes 3xx - Redirection
– Further action must be taken in order to complete
request
» 300 Resource found at multiple locations
» 301 Resource moved permanently
» 302 Resource moved temporarily
» 304 Resource has not modified (since date)

HTTP 16
HTTP 1.0
• HTTP response
– Status line
• Status-codes 4xx - Client error
– The request contains bad syntax or cannot be fulfilled
» 400 Bad request from client
» 401 Unauthorized request
» 402 Payment required for request
» 403 Resource access forbidden
» 404 Resource not found
» 405 Method not allowed for resource
» 406 Resource type not acceptable

HTTP 17
HTTP 1.0
• HTTP response
– Status line
• Status-codes 5xx - Server error
– The server failed to fulfill an apparently valid request
» 500 Internal server error
» 501 Method not implemented
» 502 Bad gateway or server overload
» 503 Service unavailable / gateway timeout
» 504 Secondary gateway / server timeout

HTTP 18
Figure 22.10 HTTP transaction

TCP/IP Protocol Suite 19


TCP/IP Protocol Suite 20
TCP/IP Protocol Suite 21
HTTP connections
Nonpersistent HTTP Persistent HTTP
• At most one object is sent • Multiple objects can be
over a TCP connection. sent over single TCP
connection between client
and server.
Non-Persistent HTTP: Response time
Definition of RTT: time for a
small packet to travel from
client to server and back.
initiate TCP
connection
Response time: RTT

• one RTT to initiate TCP request


file
connection RTT
time to
transmit
• one RTT for HTTP request file
and first few bytes of HTTP file
received
response to return
• file transmission time time time

total = 2RTT+transmit time


Figure 22.15 Example 22.8

24
Figure 22.16 Example 22.9

TCP/IP Protocol Suite 25


Persistent HTTP

Nonpersistent HTTP issues:


• requires 2 RTTs per object
• additional overhead for each TCP connection
• browsers often open parallel TCP connections to fetch referenced
objects

Persistent HTTP
• server leaves connection open after sending response
• subsequent HTTP messages between same client/server sent
over open connection
• client sends requests as soon as it encounters a referenced object
• as little as one RTT for all the referenced objects
File Transfer Protocol
(FTP)
FTP
• FTP uses the services of TCP.

• It needs two TCP connections.

• The well-known port 21 is used for the control connection and


the well-known port 20 for the data connection.
20.1 Connections: The control connection
The Data Connection

• Uses Server’s well-known port 20


1. Client issues a passive open on an ephemeral
port, say x.
2. Client uses PORT command to tell the server
about the port number x.
3. Server issues an active open from port 20 to
port x.
4. Server creates a child server/ephemeral port
number to serve the client
Creating
the data
connection
Using the data connection

• File Type :
• ASCII or EBCDIC or Image

• Data Structure :
• File Structure, Record Structure, Page Structure
• Transmission mode:
• Stream mode, Block mode, Compressed mode
Control connection

• Access Commands
• File Management
• Data Formatting
• Port defining
• File transfer
• Miscellaneous
File transfer
Example 1

https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes
Example 2
20.5
USER
INTERFACE
Solution

% ftp challenger.atc.fhda.edu
Connected to challenger.atc.fhda.edu
220 Server ready
Name: ABC12345
Password: xxxxxxx
ftp > ls /usr/user/report
200 OK
Solution

150 Opening ASCII mode


...........
226 transfer complete
ftp > close
221 Goodbye
ftp > quit
Domain Naming System
(DNS)
Introduction

1. What is the IP
address of
udel.edu ?

It is 128.175.13.92

1. What is the
host name of
128.175.13.74

It is strauss.udel.edu
The DNS is a….
• A globally distributed, scalable, reliable database
• Comprised of three components
– A “name space”
– Servers making that name space available
– The mechanism by which Internet software translates
names to attributes such as addresses
DNS as a Lookup Mechanism
• Users generally prefer names to numbers

• Computers prefer numbers to names

• DNS provides the mapping between the two


– I have “x”, give me “y”
DNS as a Database
• Keys to the database are “domain names”
– www.foo.com, 18.in-addr.arpa, 6.4.e164.arpa
• Over 200,000,000 domain names stored
• Each domain name contains one or more
attributes
– Known as “resource records”
• Each attribute individually retrievable
Global Distribution
• Data is maintained locally, but retrievable globally
– No single computer has all DNS data
• DNS lookups can be performed by any device
• Remote DNS data is locally cachable to improve the performance
DNS tree structure
• Domain name is represented in the form of labels from leaf
to root.
– An inverted tree with the root node at the top
• Each node has a label
– The root node has a null label, written as “”
An Analogy – E.164
• Root node maintained by the ITU (call it “+”)
• Top level nodes = country codes (1, 81, etc)
• Second level nodes = regional codes (1-402, 81-3, etc.)
Domain Names
• A domain name is the sequence of labels from a node to the root, separated by
dots (“.”s), read left to right
– The name space has a maximum depth of 127 levels
– Domain names are limited to 255 characters in length
• A node’s domain name identifies its position in the name space
Hierarchy of name servers
Generic domains
Generic domain labels
Block Diagram

Query Query

Foreign
User Name
Resolver
Program Server
Response
Response
Reference
Addition

Cache
Iterative Resolution
a.root
server

a3.nstl a.gtld-
d.com server
5
udel ns1.goo
server gle.com
3 iterative response (referral)7
“I don't know. Try a.root-servers.net.”
iterative response (referral) 9
“I don't know. Try a.gtld-servers.net.”
1 iterative response (referral)
iterative response (referral)
“I don't know. Try a3.nstld.com.”
2 4 “I don't know. Try ns1.google.com.”
6 iterative response
8 “The IP address of www.google.com
client 10 is 216.239.37.99.”
iterative request
“What is the IP address of
www.google.com?”
Recursive Resolution
root
server
edu 3 com
server server
7 4
udel 2 8 google
serve server
6 5
r
9

1
1 recursive request
0 “What is the IP address of
www.google.com?”
client recursive response
“The IP address of www.google.com is
216.239.37.99.”
DNS- Question Record Format

sent in query;
repeated in response

Query name
(variable length) class of network (1 = Internet)

Query type Query class 1 A Address – IPv4


(16 bits) (16 bits) 2 NS Name Server (authoritative)
5 CNAME Canonical Name (alias)
12 PTR Pointer – reverse lookup
15 MX Mail Exchange
28 AAAA Address - IPv6
252 AXFR Zone Transfer

3 r e n 5 e e c i s 4 u d e l 3 e d u 0

counts
DNS message
format

bytes 0-11
Header (12 bytes)
Query name byte 12
Question

(variable length)
Section

Query type Query Class 3 r e n 5 e e c i s


(16 bits) (16 bits) 4 u d e l 3 e d u 0
Domain Name
(variable length)
C0 0C
Answer
Section

1100000000001100 = 1210
Example forward query/response
“www.udel.edu's IP address
“What is the IP address is 128.175.13.63.”
of www.udel.edu?”
same ident 0x8180 Hdr
Hdr ident 0x0100

Qry 3 'w' 'w' 'w' Qry


3 'w' 'w' 'w' 4 'u' 'd' 'e'
4 'u' 'd' 'e' 'l' 3 'e' 'd'
'l' 3 'e' 'd' 'u' 0 0x0001(A)
'u' 0 0x0001(A)
0x0001(IN)
0x0001(IN)
0xC00C 0x0001(A) Ans
flags: recursion desired (RD)
0x0001(IN) 0x0000...
flags: query response (QR),
recursion desired (RD), ...0xB2F5 0x0004
recursion available (RA) 0x80AF0D3F
TTL: 45301 seconds ≈ 12.6 hours (128.175.13.63)
...
19
Example inverse query/response
“What is the name of the “The host at 128.175.13.63
host at 128.175.13.63?” is named www.udel.edu.”
Hdr ident 0x0100 same ident 0x8180 Hdr

Qr 2 '6' '3' 2 2 '6' '3' 2 Qry


y '1' '3' 3 '1' '1' '3' 3 '1'
'7' '5' 3 '1' '7' '5' 3 '1'
'2' '8' 7 'i' '2' '8' 7 'i'
'n' '-' 'a' 'd' 'n' '-' 'a' 'd'
'd' 'r' 4 'a' 'd' 'r' 4 'a'
'r' 'p' 'a' 0 'r' 'p' 'a' 0
0x000C(PTR) 0x0001(IN)
0x000C(PTR) 0x0001(IN) 0xC00C 0x000C(PTR) Ans
0x0001(IN) 0x0000...
...0xB003 0x000E
3 'w' 'w' 'w'
4 'u' 'd' 'e'
TTL: 45056 seconds ≈ 12.5 hours 'l' 3 'e' 'd'
'u' 0
...

You might also like