| Andrei Voropaev 2005-01-14, 8:57 am |
| On 2005-01-14, Kanti <kanti_14@rediffmail.com> wrote:
> Hi all
>
> I have got a doubt regarding TCP software embedded in OS. TCP is meant
> for reliable transmission, receipt of acknowledgements..etc.. but I
> want to know one thing regarding receipt of acknowledgement for data
> segments sent and window adjustment in TCP.
>
> First I create a stream sockets at two ends and do all the stuff to
> establish the connection between these two sockets. now I send a
> segment (from my application) to the other end (say from a to b). Now
> my question is how this segment will be acknowledged? should I need to
> echo back or send some type of response saying u'r segment reached to
> the sender from the other side application(as acknowledgent)? or this
> will be handled by the TCP software in OS?
>
> now if it is handled by the underlying TCP software( because an ack
> field is there in TCP header) then what should I do to extracr this
> info from tcp header?
> (ie can we extract TCP header and abserve at the application level?)
If your application at point 'a' wants to be sure that application at
point 'b' has received the data, then your application at point 'b'
should send some acknowledgment. See for example HTTP protocol.
TCP does reliable transmission. It just means that the packet that you
put into systems outgoing buffer will be delievered to the systems
incoming buffer of the peer (provided that network didn't go down). But
if the application on the other side stopped reading from the systems
incoming buffers, then of course it won't receive the data. This is the
first reason why explicit acknowledgment from remote application is
good.
Going back to TCP. If the network link (physical) was lost, then TCP
will try to resend your data untill certain timer expires. This timer is
pretty long. If the link comes back, then the data will be delivered,
otherwise your socket will get an error (this should be visible in
poll/select). Most of the time such long delays are not acceptable, so
explicit acknowledgment again can help in this situation.
One more point. With networks usually one can not be sure which program
listens on the other side. Receiving of appropriate acknoledgments
definetely help :)
Of course if none of the above makes concerns, then you can simply rely
on the fact that TCP will either transfer your data to the peer, or will
report an error. Read more on that in man 7 tcp man 7 socket.
--
Minds, like parachutes, function best when open
|