Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Connection?

I am getting confused between TCP being Connection oriented and UDP being connectionless so please somebody clarify this.

  • Every communication between two computers whether its TCP or UDP is via packets. There is no hard wire connection between two peers whether its TCP or UDP. Then why TCP is said to be connection oriented just because it retransmits the packets if no acknowledgement is received or it embeds sequence number inside the packets ?

  • Whats the actual meaning of connection ? Does the routers along the path between two communicating peers booked for some time to accept packets for that particular connection ?

EDIT

  • When do you say connection between two points established?

Thanks

like image 282
Xinus Avatar asked Nov 29 '22 19:11

Xinus


2 Answers

A connection is simply a virtual pathway between two endpoints. With TCP, you open up the connection and start sending data through. It's guaranteed to arrive at the other end in order (assuming the network doesn't fail). Then you close down the connection.

For the duration of the connection, the two ends talk to each other, acknowledging receipt of packets, to ensure there's no loss or duplication.

With UDP, it's slightly different. You basically just throw a packet out there with a destination address and it may or may not arrive - that's the U in UDP (unreliable).

You shouldn't be lulled into thinking the connection of TCP results in all packets taking the same physical path. They will be routed around problem areas if necessary.

As for your update, the connection is established after the following has happened:

  • a SYN packet has been sent from the initiator.
  • the responder has sent back a SYN-ACK packet.
  • the initiator has sent back another ACK packet.

This is the session establishment protocol for TCP. The packets themselves are normal packets with the SYN and/or ACK flags set in the header.

The seminal book on TCP (and other protocols) is Stevens, get yourself a copy of this if you want a dead-tree version - I've had this for ages. Or, of course, there's the Wikipedia stuff. Both of these are pretty heavy going for the casual enquirer, but well worth it if you're at all interested in going deeper - my own preference would be for the book, it ranks up there with Knuth on my bookshelf.

like image 98
paxdiablo Avatar answered Dec 04 '22 14:12

paxdiablo


Yes, TCP embeds sequence numbers, and does a whole lot of other processing to "simulate" a dedicated point-to-point connection over a packet-oriented, connection-less network.

UDP does not; each datagram is delivered totally independently of any other datagrams.

like image 30
unwind Avatar answered Dec 04 '22 16:12

unwind