Paper C7 Computer Network Assignments
Paper C7 Computer Network Assignments
detection technique
● It is one of the most powerful and commonly used error detection technique
/code
● Basic Approach
● Given an m-bit block of bits, the sender generates an n-bit sequence, known as
frame check sequence (FCS).
● The result frame consists of m bits data +n bits FCS.
● It is divisible by a some predetermined number.
● The receiver divides the incoming frame by the same number and if there is no
remainder, it assumes no error and accept data.
CRC – [Data- m bits and divisor – n+1 bits]
Data CRC
CRC - Example
● Reason
● For reliable and efficient data communication a great deal of coordination is
necessary between sender and receiver. There exists speed and memory
mismatch between sender and receiver device.
● A fast sender should not overwhelm a slow receiver.
● If error occurs during transmission, it is necessary to devise mechanism to
correct it.
● Error can occur any time and any where.
Error Control Technique - ARQ
Frame 0
ACK 1
Frame 1
ACK 0
Stop and Wait ARQ Algorithm
Sender’s End
//SN store frame sequence number if(response=ACKFrame)
// Data array stores data frames to send // send next frame for positive ACK
SN ← 0 i← i+1
i←0 SN ← (SN+1)%2
while (i <= N) }
{ if(response=NAKFrame)
sframe.sequenceNo ← SN }
sendFrame(sframe) }
response ← receiveResponse()
Stop and Wait ARQ Algorithm
Receiver’s End
// N is total number of frames to receive if(CRC=0)
{
// Data array stores received data frames
// send ACK, accept data and prepare for next
i←0 frame
so send positive acknowledgement ACK else // send NAK and prepare for the same frame
send negative acknowledgement NAK */ NAKFrame ← create NAK frame
sendResponse(NAKFrame)
}
}
Question 3 Simulate Go Back N ARQ Sliding Window Flow
Control based error control technique
F0
F1
F2
ACK3
F3
Error in F3
F4 NAK3
Go Back N All subsequent discarded
F5
(frame 3)
And retransmit F3
frame N and all F4
subsequent F5
frames
Go Back N ARQ Algorithm
Sender’s End
/*SN store frame sequence number N is total if(response=ACKFrame)
number of frames to send and Data array stores
data frames to send*/ {
SN ← 0 , i ← 0 // send next set of frame for positive ACK
while (i <= N) }
{ if(response=NAKFrame)
for j← 0 to windowSize - 1 {
{ sframe ← create new frame // Go Back to frame with seuqnece Number N
sframe.data ← data[i] for negative ACK
sframe.sequenceNo ← SN SN ← response.sequenceNo
SN ← (SN+1)%windowSize }
F0
F1
F2
ACK3
F3
Error in F3 but
F4 NAK3
Selective Repeat All subsequent accepted
F5
(frame 3)
And retransmit F3
frame 3 only
Selective Repeat ARQ Algorithm
Sender’s End
/*SN store frame sequence number N is total if(response=ACKFrame)
number of frames to send and Data array stores
{
data frames to send*/
// send next set of frame for positive ACK
SN ← 0 , i ← 0
}
while (i <= N)
if(response=NAKFrame)
{
{
for j← 0 to windowSize - 1
// Selective repeat frame with sequence no N for negative
ACK
{ sframe ← create new frame
sframe ← create new frame
sframe.data ← data[i]
sframe.data ← data[i]
sframe.sequenceNo ← SN
sframe.sequenceNo ← SN
sendFrame(sframe)
SN ← (SN+1)%windowSize
SN ← (SN+1)%windowSize
}
response ← receiveResponse() , i ← i+1
}
}
Selective Repeat ARQ Algorithm
Receiver’s End
// N is total number of frames to receive if(CRC=0 and newSN=oldSN+1)
// Data array stores data received frames {
i ← 0, SN ← 0 data[i] ← rframe.data
while (i <= N) i← i+1
{
}
oldSN ← SN
else
for j=0 to windowSize-1
{
{ rframe ← receiveFrame()
// send NAK and go back to Nth frame
//compute CRC to detect error in frame
NAKFrame ← create NAK frame
CRC ← computeCRC(rframe),
NAKFrame.sequenceNo ← oldSN
newSN ← rframe.sequenceNo
sendResponse(NAKFrame)
/*if CRC is zero and frame is not out of
sequence it means error free frame so accept /*accept out of order remaining frames but
else reject and also discard future frames*/ later on put out of order frame in correct
sequence */
}
Selective Repeat ARQ Algorithm
Receiver’s End
if(j=windowSize)
{
/* if all the frames are received error free then send cumulative
acknowledgement for next frame to receive*/
ACKFrame ← create ACK Frame
ACKFrame.acknowledgementNo ← (newSN+1)%windowSize
}
}
Question - 5 Simulate and implement Dijkstra’s Algorithm
for computing shortest path
Dijkstra’s algorithm is used to compute shortest path from a single source node to
all other nodes in the network.
The routing table is used for forwarding of incoming packets to outgoing lines.
This algorithm starts from the start node S and proceeds by selecting a node from
OPEN which has minimum total cost. The cost information is stored in array C.The
algorithm stops when OPEN becomes empty.
This array can be used to construct complete path from Start bode S to any
destination node.
}
A is start vertex , put A in OPEN
Dijkstra’s Algorithm Example
3 OPEN A(0)
4 B
F
A0
1
CLOSED
2 3
5
2
C
Node Parent
10 A
8
B
C
D E
3 D
F
Pick minimum cost node N from OPEN - A(0)
Compute cost of adjacent nodes of B,C and D
Dijkstra’s Algorithm Example of A and put in OPEN is not already present
2 3
5
2
C2
Node Parent
10 A
8
B A
C A
D5 E
3 D A
F
Cost of nodes B,C and D updated
Pick minimum cost node N from OPEN - C(2)
Compute cost of adjacent nodes B,D,E and F
Dijkstra’s Algorithm Example of C and put in OPEN is not already present
2 3
5
2
C2
Node Parent
10 A
8
B C
E C A
D5
12
3 D A
E C
F C
Cost of nodes B,F and E updated
Pick minimum cost node N from OPEN - B(3)
Compute cost of adjacent nodes F of B and
Dijkstra’s Algorithm Example put in OPEN is not already present
2 3
5
2
C2
Node Parent
10 A
8
B C
E C A
D5
12
3 D A
E C
F C
No node updated
Pick minimum cost node N from OPEN - D(5)
Compute cost of adjacent nodes E of D and
Dijkstra’s Algorithm Example put in OPEN is not already present
2 3
5
2
C2
Node Parent
10 A
8
B C
C A
D5 E8
3 D A
E D
F C
Cost of nodes E updated
Pick minimum cost node N from OPEN - F(5)
Compute cost of adjacent nodes E of F and
Dijkstra’s Algorithm Example put in OPEN is not already present
3 OPEN E(7)
4 B3
F5
A0
1
CLOSED A(0) C(2) B(3) D(5) F(5)
2 3
5
2
C2
Node Parent
10 A
8
B C
C A
D5 E7
3 D A
E F
F C
Cost of nodes E updated
Pick minimum cost node N from OPEN - E(7)
OPEN empty - Terminate
Dijkstra’s Algorithm Example
3 OPEN
4 B3
F5
A0
1
CLOSED A(0) C(2) B(3) D(5) F(5) E(7)
2 3
5
2
C2
Node Parent
10 A
8
B C
C A
D5 E7
3 D A
E F
F C
Algorithm Terminates
Dijkstra’s Algorithm Path and Routing Table
Node Parent
Node and Parent Table is
A used to construct shortest
path table
B C
Routing Table of Node A
C A Node Path Cost reflects shortest path to
D A A 0 each and every node from
node A
E F B ACB 3
Dest. Next Cost
F C C AC 2 Node
D AD 5 A 0
E ACFE 7 B C 3
F ACF 5 C C 2
D D 5
E C 7
F C 5
Question 6 Explain the following internetworking devices