Merged CN
Merged CN
Computer Networks
Medium Access Control
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.
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]
Random Waiting
times
Wasted time
Non-Persistent CSMA
a collision.
• Stop the ongoing frame transmission(when XOR=1).
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.
• 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
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.
• 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
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)
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
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 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*/
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
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
<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
<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
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
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.
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
4 1 3 10
2 2 ∞
∞ C D E
5 8 ∞ 4 6
1
F G
∞ ∞
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
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
4 1 3 10
2 2 ∞
∞ C D E
5 8 ∞ 4 6
1
F G
∞ ∞
• 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).
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.
• Ok, now that we know how to distribute LSPs, how are they
used to determine routes?
b) Essentially, the algorithm runs at each router, computing each possible path to
the destination, adding up each cost
Dijkstra’s
Received Link State Algorithm IP Routing
LSAs Database Table
6 2
A B C 5
2 1 2 G
2 4
D E F 1
C (0)
Dijkstra’s LSR Algorithm
a) Examine C’s LSP
a) Add F, G, and B to TENT
C (0)
C (0)
(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)
(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)
C (0)
(2) F B (2)
C (0)
(2) F B (2)
(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)
(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)
(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
• fleet in oceans
• historical cites
• festival ground
On-demand vs. Table-driven
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
B
RREQ:S
S A
C D
B
RREQ:S
S A
C D
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
[S] Z
S E
F
B
C M L
J
A G
H D
K
I N
Z
S [S,E]
E
F
B
C M L
J
A [S,C] G
H D
K
I N
Z
S E
F [S,E,F]
B
C M L
J
A G
H D
[S,C,G] K
I N
Z
S E
F [S,E,F,J]
B
C M L
J
A G
H D
K
I [S,C,G,K] N
Z
S E
[S,E,F,J,M]
F
B
C M L
J
A G
H D
K
I N
Z
S RREP [D,J,F, E,S]
E
F
B
C M L
J
A G
H D
K
I N
DATA [S,E,F,J,D]
Z
S E
F
B
C M L
J
A G
H D
K
I N
• An IP address:
- is a 32 bit long identifier
- encodes a network number (network prefix)
and a host number
Dotted Decimal Notation
• 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
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
128.143 137.144
Problems with Classful IP Addresses
• 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
subnet
network prefix number
host number
* 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
128.143.0.0/16
Same Network with Subnets
Same network with different subnetmasks
128.143.137.0
Subnet
Subnetting Example
• 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.
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.
• 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
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
24
Figure 22.16 Example 22.9
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.
• 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
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
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)
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
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