during a file transfer. The TCP Layer at the destination end will:
• let the TCP Layer at the source know how many packets the destination currently has room for
• watch for the packets
• piece them together as they arrive, possibly out of order (again, to reassemble them properly, we use
the sequence numbers within the packets)
• send acknowledgement messages to the source node as packets arrive
The destination will also look at the error-checking bits in each package, and will give negative acknowledgements
if errors are detected. If the source does not receive an acknowledgement for a given packet
within a preset amount of time, it will time out and resend the packet. It will also do so if it receives a
negative acknowledgement for a packet. For this reason, TCP is called a reliable protocol (though this term
should not be taken to mean "100% reliable").
4.1.2 UDP
UDP, on the other hand, is connectionless and unreliable. UDP is pretty reliable if confined to a LAN, but
problems may occur elsewhere, because for example a buffer at a router might be full and the datagram
(the term used instead of packet in the UDP case) is dropped. UDP's virtue is that it is simple and thus has
very little overhead, compared to TCP, which spends a lot of time negotiating and maintaining a connection
between the source and destination nodes.
UDP is useful in applications in which we can afford to lose some messages, such as a time server, which
broadcasts time of day to client machines; if a client misses one message this is no problem, as it will pick
up the next one. Thus the unreliability of UDP is not a problem, and the low overhead of UDP is a virtue.
Similarly, suppose we are broadcasting a graphics animation or a movie over a network. Loss of one message
would result in nothing more than a tiny "blip" on the screen, barely noticeable to the viewer, so again
reliability is not an issue. Moreover, in real-time applications like this, we can hardly afford the delay
caused by retransmitting when messages are lost or corrupted, which is what TCP would do.
Also, UDP is capable of broadcasting, i.e. sending out just one copy of a message to all machines connected
to the same Ethernet. If we do wish to send the same message to everyone, the ability to do so using just
one copy can really help reduce traffic on the network.
9
4.1.3 Stream Vs. Datagram Communication
It is extremely important to keep in mind that TCP views all the bytes it sends during one socket
connection to consist of one long stream of bytes, with no subdivisions of any kind.
Suppose for example machine A executes
write(SDA,BufA1,20);
write(SDA,BufA2,30);
where SDA is a TCP socket. You will see the details of writing to a socket later, but for now suffice it to say
Overview of Computer Networks
Comenzar desde el principio
