Skip to main content

TCP Question

More
18 years 4 months ago #16277 by Smurf
TCP Question was created by Smurf
So, I have just been reading the Networking Section to understand more on how TCP works to try and diagnose an issue i am having. I wondered if someone could please clarify something for me that doesn't seem to make sense on the "Quick TCP Overview Page".

So here is the bit of text i am refering to (ommiting the diagram)

Acknowledgments
Reliable data delivery ensures the integrity of a stream of data sent from one machine to the other through a fully functional data link. This guarantees the data won't be duplicated or lost. The method that achieves this is known as positive acknowledgment with retransmission. This technique requires a receiving machine to communicate with the transmitting source by sending an acknowledgment message back to the sender when it receives data. The sender documents each segment it sends and waits for this acknowledgment before sending the next segment. When it sends a segment, the transmitting machine starts a timer and retransmits if it expires before an acknowledgment is returned from the receiving end.
This figure shows how the Acknowledgments work. If you examine the diagram closely you will see the window size of this transfer which is equal to 3. At first, Host B sends 3 data segments to Host A and they are received in perfect condition so, based on what we learned, Host A sends an "ACK 4" acknowledging the 3 data segments and requesting the next 3 data segments which will be 4, 5, 6. As a result, Host B sends data segments 4, 5, 6 but 5 gets lost somewhere along the way and Host A doesn't receive it so, after a bit of waiting, it realises that 5 got lost and sends an "ACK 5" to Host B, indicating that it would like data segment 5 retransmitted. Now you see why this method is called "positive acknowledgment with retransmission".


The thing that is a little confusing is that it says that "The sender documents each segment it sends and waits for this acknowledgment before sending the next segment. When it sends a segment, the transmitting machine starts a timer and retransmits if it expires before an acknowledgment is returned from the receiving end."

Then when we get to the example it says that "Host B sends data segments 4, 5, 6 but 5 gets lost somewhere along the way and Host A doesn't receive it so, after a bit of waiting, it realises that 5 got lost and sends an "ACK 5" to Host B, indicating that it would like data segment 5 retransmitted. Now you see why this method is called "positive acknowledgment with retransmission"

Can someone explain which way it actually is as this seems a contradiction ?

Thanks in advance everyone

Wayne Murphy
Firewall.cx Team Member
www.firewall.cx

Now working for a Security Company called Sec-1 Ltd in the UK, for any
Penetration Testing work visit www.sec-1.com or PM me for details.
More
18 years 4 months ago #16278 by TheBishop
Replied by TheBishop on topic Re: TCP Question
You're reading it right but having re-read it myself I can see where the confusion lies. Real-world TCP does work with a window size, whereby the sender can send multiple segments of data which are then all acknowleged by a single ACK. This gives greater efficiency as there is less ACK overhead per set amount of data transferred. The first part of the description, which I think is the bit that's confusing you, isn't saying the sender sends one segment then waits for the ACK before it will send the next one (although it does read a bit as if that's what it is suggesting). What it's saying is the same as I've explained above; that the sender keeps track of the segments sent and won't send any more than its window size will permit until it has an ACK from the other end.
I hope that makes sense
More
18 years 4 months ago #16279 by Smurf
Replied by Smurf on topic Re: TCP Question
Hi "TheBishop",

Thanks very much for the extra detail. It still isn't quite fitting into place. The section says that its got a window size of 3 and that 3 segments are being sent before a ACK is sent back (I appreciate that it does actual deal with Windows Size in Data and not segments and that this is for illustration purposes).

The bit that is confusing for me is; If the sender starts a timer going to wait a set amount of time before it receives ACK's, why does it say that the receiver waits a set amount of time before sending a ACK to retransmit ? Does this mean that both sides have a timer ? Hope that makes sense.

Wayne Murphy
Firewall.cx Team Member
www.firewall.cx

Now working for a Security Company called Sec-1 Ltd in the UK, for any
Penetration Testing work visit www.sec-1.com or PM me for details.
More
18 years 4 months ago #16280 by Dove
Replied by Dove on topic Re: TCP Question
TCP using the Windowing technology for reliable data transmission.
As per your example the window size is marked as 3 that is the sender will transmit the first segment 1,2 & 3 and it will wait for ACK from the receiving end. Once the receiving end received all the data which as been sent by source then it send a request/ACK to send the next segment (Segment 4).

As per your scenario while sending 4,5 & 6, 5 get lost right, the TCP header having the squence number, while receiving the segment the receiver will chk the sequence number if any of the intermitent packet is lost r not. if any thing is lost then it will raise the request/ACK to resend the missing packet. So when the 5th one get lost it will find out and raise a request to resend the same. Once the it received all the packet on that segment it will ACK/ request to send the next Segment.

The main advantage of the Windowing is to avoid retransmitting the whole data.


I hope I had answered to your query.



Regards,
Dove.


Dove
More
18 years 4 months ago #16282 by Smurf
Replied by Smurf on topic Re: TCP Question
Hi "Dove",

Thanks very much for the extra info. This makes sense however just the one question now. How does the Receiver decide that it has missed Segment 5 if these can be received out of order in the first place how does it know that its not on its way ? Does the Receiver also have a time limit it waits before it will give up on waiting for receiving it ?

Sorry if these are simple questions, just trying to get my head around the lower levels of TCP so i wanna make sure my understanding so far is correct.

Cheers

Wayne Murphy
Firewall.cx Team Member
www.firewall.cx

Now working for a Security Company called Sec-1 Ltd in the UK, for any
Penetration Testing work visit www.sec-1.com or PM me for details.
More
18 years 4 months ago #16306 by Dove
Replied by Dove on topic Re: TCP Question
In TCP Sliding Window each segment / Window having the unique Sequnce No. and ACK / Next Window number

The ACK / Next Window Number calculated as follows
Initial Seq.No+Total Size of the Window


For Example
========

Host A (Sender)

Data : A B C D E F G H
Seq.No : 0 1 2 3 4 5 6 7
Next Seq.No (ACK) : 1 2 3 N* 5 6 7 N*



Host B (Receiver)
Data : A B D
Ack : 1 2 N*

Note *: Next Window

Each TCP segment having the self unique Sequence no and Next Seq.No also called as ACK no, it represent the packet which the receiver expect to receive. Once the receiver received a data it will ACK the same ACK no which is received from sender.

So as per the Example data 'C' was lost, so it will send Duplicate ACK / resend request to sender.

Once it received the lost data it reorganise the received data and verify the sequence. If It matches with the Next Window Add/Seq No then it will send the ACK to send the next window.



Hope I had answer to your question.


Regards,
Dove


Dove
Time to create page: 0.132 seconds