Skip to contentSkip to conversation

seq in tcp protocol

DISCUSSION ishare 4 participants 8 messages Mar 22, 2013 – Mar 30, 2013

lore
Share & tools
lore

ishare

author
#0 lore raw

If I send a buffer with tcp protocol , the data is separated to serveral packets , each packet will have a seq number with it ,which ensures the recipient read this buffer in right orfer .

my question is : how the recipient know which is the end packet of this queue ? Is there data indicate the total quantity of packets composing this buffer ?

thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw
Quoted 7 lines · ishare

If I send a buffer with tcp protocol , the data is separated to serveral packets , each packet will have a seq number with it ,which ensures the recipient read this buffer in right orfer .

my question is : how the recipient know which is the end packet of this queue ? Is there data indicate the total quantity of packets composing this buffer ?

TCP is a stream protocol. There is no concept (at the application level anyway) of packets in TCP. The receiving TCP/IP stack is free to offer the data to the application whenever it decides to, in however many lumps as it decides to. Similarly, the sending TCP/IP stack may decide to wait to send data until it's received more from the sending application before packaging it and sending it to the receiver.

You may find http://en.wikipedia.org/wiki/Nagle%27s_algorithm
interesting.

Regards,
Kristof

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

author
#2 lore raw
Quoted 8 lines · Kristof Provost
Quoted 7 lines · ishare

If I send a buffer with tcp protocol , the data is separated to serveral packets , each packet will have a seq number with it ,which ensures the recipient read this buffer in right orfer .

my question is : how the recipient know which is the end packet of this queue ? Is there data indicate the total quantity of packets composing this buffer ?

Quoted 6 lines

TCP is a stream protocol. There is no concept (at the application level anyway) of packets in TCP. The receiving TCP/IP stack is free to offer the data to the application whenever it decides to, in however many lumps as it decides to. Similarly, the sending TCP/IP stack may decide to wait to send data until it's received more from the sending application before packaging it and sending it to the receiver.

When one send system api is called , will all data in the buffer be sent out together at one time ?

Quoted 7 lines

You may find http://en.wikipedia.org/wiki/Nagle%27s_algorithm
interesting.

Regards,
Kristof

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#3 lore raw
Quoted 10 lines · ishare
Quoted 6 lines

TCP is a stream protocol. There is no concept (at the application level anyway) of packets in TCP. The receiving TCP/IP stack is free to offer the data to the application whenever it decides to, in however many lumps as it decides to. Similarly, the sending TCP/IP stack may decide to wait to send data until it's received more from the sending application before packaging it and sending it to the receiver.

When one send system api is called , will all data in the buffer be sent out together at one time ?

No. There are no guarantees about how many TCP packets will be used to send your data, or in how many buffers it will be offered to the application on the receiving side.

Kristof

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#4 lore raw
In reply to ishare

FIN flag is set to terminate a TCP session, similarly SYN flag is set to indicate beginning of a TCP transmission.
So stream tear-down is initiated as soon as receiver gets a packet with FIN flag set to 1. Though there are some intricacy and variation of it.

http://www.fluffyspider.com/resources/papers/TTCPIMG00011.GIF

http://www.fluffyspider.com/resources/papers/t_tcp.html

Quoted 24 lines · ishare
Quoted 8 lines · Kristof Provost
Quoted 7 lines · ishare

If I send a buffer with tcp protocol , the data is separated to serveral packets , each packet will have a seq number with it ,which ensures the recipient read this buffer in right orfer .

my question is : how the recipient know which is the end packet of this queue ? Is there data indicate the total quantity of packets composing this buffer ?

Quoted 6 lines

TCP is a stream protocol. There is no concept (at the application level anyway) of packets in TCP. The receiving TCP/IP stack is free to offer the data to the application whenever it decides to, in however many lumps as it decides to. Similarly, the sending TCP/IP stack may decide to wait to send data until it's received more from the sending application before packaging it and sending it to the receiver.

When one send system api is called , will all data in the buffer be sent out together at one time ?

Quoted 4 lines

You may find http://en.wikipedia.org/wiki/Nagle%27s_algorithm
interesting.

Quoted 8 lines
Quoted 3 lines

Regards,
Kristof

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#6 lore raw
Quoted 4 lines · ishare

How does the sender decide how many packet is needed to transfer one buffer and manager the seq orders of them ?

http://en.wikipedia.org/wiki/Nagle%27s_algorithm

Signature · 7 lines
Kristof

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
#7 lore raw

I could be wrong, but I guess linux uses Minshall's modification of Nagle's algorithm.

Quoted 6 lines
Quoted 5 lines

How does the sender decide how many packet is needed to transfer one
buffer and
manager the seq orders of them ?

http://en.wikipedia.org/wiki/Nagle%27s_algorithm

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs