Q & A on TCP: Connection-oriented or connectionless?

Q: Part of the definition, if I understand correctly, of connection oriented service is that a virtual connection is arranged between sender and receiver for the whole of the transfer.

How can TCP be connection oriented, if its segments are encapsulated in IP datagrams, which are a connectionless service?

A: You are correct that TCP uses a connectionless service (IP) to exchange segments. The key to understanding TCP is to observe that although TCP provides a CO (i.e., virtual circuit) abstraction to applications that use it, the TCP protocol modules on the sending and receiving machines do not require a CO network. In fact, the whole idea of building TCP over IP seems like a paradox because:

		TCP provides			IP provides
	---------------------------	----------------------------
	connection-oriented service	connectionless service
	stream interface		datagram interface
	flow control			no flow control
	congestion control		no congestion control
	reliability:			no guarantees about
	  no loss			  loss
	  no duplication		  duplication
	  no out-of-order delivery	  out-of-order delivery

In other words, TCP provides *more* service than IP. To achieve such features TCP uses mechanisms such as acknowledgements, window advertisements, and timers that allow it to detect and recover from loss, duplication, and out-of-order delivery.