Step-1:
Sender:
1. Sender wait for the data from upper layer.
2. When sender gets data then it makes Data into Packet
3. But sender has no reliable channel to send data reliably. So it send unreliable data
Receiver:
1. When receiver get data from lower level, it think it is reliable packet.
2. Then it will extract the packets into data
3. Then it deliver data to its higher level
In this step had no solution. Cause receiver can get corrupted data. But how receiver will detect the data is corrupted. So to send error free data sender and receiver uses Error detection techniques. Sender calculates data and also sends the result and receiver calculates data and matches the result with sender’s value. There are many techniques to detect error.
Step-2:
Using one of these Error Detection techniques, sender will send data with result but when receiver will detect error or not, sender should know that. So receiver will send an acknowledgement (ACK) for error free data and receiver will send a negative acknowledgement (NAK) for corrupted data.
Sender:
1. Sender wait for the data from upper layer.
2. When sender gets data then it Checksum data
3. Then makes data into packets
3. Send unreliable data.
4. Then the sender wait for either ACK or NAK from the receiver.
If receiver get corrupted then it will send an NAK
5. The sender will send the packet again.
or If receiver get the error free data then it will send ACK
5. Then sender will again wait for the data from upper layer.
Receiver:
Receiver can get corrupted or uncorrupted data. If receiver get uncorrupted data from lower level then
1. It thinks it is reliable packet. Then it will extract the packet into data
2. Then it deliver data to its higher level
3. Then it make packet for send acknowledgement
4. Then it send acknowledgement to sender
On the other hand if it get corrupted data then
5. It make packet for a NAK and send it to sender
Problem:
When receiver send ACK/NAK, then ACK/NAK can be corrupted. When sender get corrupted ACK/NAK then it send again the packet. So at the receiver end data can make duplicate. Example:
we want to send --- today is our networking class.
Receiver get --- today is our our networking class class
Now what can we do to solve this problem? We can solve this problem by giving packet number. We can give packet number like this-1, 2, 3, …1000...and more. But it is a problem if the number of packets are huge then number will be big problem. So we can solve this by 0 and 1. Cause duplicate occurs in two packets. So consider this numbering all packet by 0 and 1.
Step 3:
Sender:
1. Sender wait for the data from upper layer.
2. When sender gets data then it Checksum data
3. Then makes data into packets
3. Sends unreliable packet 0
4. Then the sender wait for either ACK or NAK from the receiver.
If receiver get corrupted packet 0 then it will send an NAK, The sender will send the packet 0 again.
or If receiver get the error free data then it will send ACK
7. Then sender will again wait for the data from upper layer and send packet 1
Receiver:
When it needs packet 0, it can receive 3 types of data - Corrupted packet 0, uncorrupted packet 0 and uncorrupted packet 1.
If receiver get corrupted packet 0
1. It will send a NAK to sender
Or when receiver get uncorrupted packet 1.
1. Then it should be send NAK but receiver yet has no power, so it sends ACK
Or when receiver get uncorrupted packet 0
1. Then it will extract the packet into data
2. Then it deliver data to its higher level
3. Then it make packet for send acknowledgement
4. Then it send acknowledgement to sender
Problem:
Here we saw the duplicate ACK. So we can number also ACK and omit the NAK.
Step 4:
Sender:
1. Sender wait for the data from upper layer.
2. When sender gets data then it Checksum data
3. Then makes data into packets
3. But sender has no reliable channel to send data reliably. So it send unreliable data
4. Then the sender wait for either ACK either packet 0 or 1.
If sender get corrupted ACK or ACK for packet 1, The sender will send the packet again.
or If sender get the uncorrupted ACK or ACK for packet 0, then sender will again wait for the data from upper layer
Receiver:
When it needs packet 0, it can receive Uncorrupted packet 0 and uncorrupted packet 1.
If receiver get uncorrupted packet 1
1. Then it send ACK1
Or when receiver get uncorrupted packet 0
1. Then it will extract the packet into data
2. Then it deliver data to its higher level
3. Then it make packet for send ACK 0
4. Then it send ACK 0 to sender
Problem:
Data can be lost on the way. ACK can be lost. What will do sender & receiver. How many times they will wait. They will wait for a certain time. So we have to use timer in this program. What will we do with timer?
1. start timer each time when packet sent
2. respond a timer interrupt
3. stop timer
Step 5:
Sender:
1. Sender wait for the data from upper layer.
2. When sender gets data then it Checksum data
3. Then makes data into packets
3. Sender sends unreliable data
4. Then the sender wait for ACK either packet 0.
If corrupted ACK for packet 0 or ACK for packet 1
5. Then it will do nothing. It will wait for time out. If Timeout -
6. Then it will send packet 0 again
7. Start the timer
Or if get uncorrupted and ACK 0
8. Then sender will do nothing. It will wait.
During waiting one thing can be happen receiver sends ACK but didn’t reach in time. Sender will count time out and send again. It will make duplicate at receiver. Receiver also sends again that data reached.
8. Then sender will do nothing
Receiver:
1. When it needs packet 0 and it will get uncorrupted packet 1
2. Then it will do nothing. It will wait for time out. If Time out
3. Then it will send packet again
If receiver get uncorrupted ACK 0
1. Then it will extract the packet into data
2. Then it deliver data to its higher level
3. Then it make packet for send ACK 0
4. Then it send ACK 0 to sender
As a sender same thing can happen at receiver. Sender sends data but will not reach in time. So at receiver end wait for time out and after timeout it will send to send again. Sender will send again but by this time 1st data has reached so second data is duplicate.
Then receiver will do nothing.
This is the main theme of Stop & Wait Protocol.
To follow this protocol our 3rd problem that was error detection is solved. Stop and wait protocol is long time process handle with only one packet at time. As a result it takes time. If there any other protocol who can handle multiple packets at a time so it will faster than before.
There is another protocol Go-Back-N.
to continue reading click on Next
Click image to go:
No comments:
Post a Comment