What is a connection?

I get confused between TCP, which is connection-oriented, and UDP, without establishing a connection, so please someone clarify this.

  • Each communication between two computers is via TCP or UDP through packets. There is no hard connection between the two peers, be it TCP or UDP. Then why is TCP called a connection oriented only because it retransmits packets if confirmation is not received or it does not insert the sequence number inside the packets?

  • What is the actual meaning of the connection? Do routers spend some time along the path between two communicating peers in order to receive packets for this particular connection?

EDIT

  • When you say that there is a connection between two set points?

thanks

+4
source share
5 answers

A connection is simply a virtual path between two endpoints. Using TCP, you open a connection and start sending data. It is guaranteed to come to the other end (provided that the network does not work). Then you close the connection.

Throughout the connection, both ends talk to each other, acknowledging receipt of packets to ensure that there is no loss or duplication.

With UDP, this is a little different. You basically just drop the packet with the destination address there, and it may or may not arrive - that U is in UDP (unreliable).

You should not be lulled into thinking about connecting TCP results in all packets that take the same physical path. If necessary, they will be broken down around problem areas.

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

  • a SYN packet was sent from the initiator.
  • the defendant sent back the SYN-ACK packet.
  • The initiator sent another ACK packet back.

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

A basic book on Stevens TCP (and other protocols), get yourself a copy of this if you want to have a dead version - I've had it for ages. Or, of course, there is Wikipedia . Both of them are pretty heavy for a random enquirer, but it's worth it, if you're even interested in going deeper โ€” my own preferences would be for a book, it takes Knut there on my bookshelf.

+8
source

Yes, TCP combines serial numbers and performs most of the other processing to "simulate" a dedicated point-to-point connection over a packet-oriented network without connecting.

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

+5
source

First, I will answer your second question. What you wrote (โ€œpath establishmentโ€), which occurs in some network architectures (such as GSM voice calls) but not on the Internet, is called circuit switching. When switching channels, the network infrastructure itself is aware of the connection between the two endpoints. However, the TCP / IP stack is for packet switching. This means that each packet represents a separate piece of information that is delivered to another endpoint and is not related to any other packet (for example, a message message).

As a result, the lower layer protocols in the IP stack do not guarantee that:

  • packages are received at destination
  • packets are received in any particular order
  • packets are received at the destination only once

UDP, in particular, is not trying to solve these problems. TCP, on the other hand, must get rid of these problems. It uses confirmations and serial numbers of packets for their processing. In TCP, one packet is not associated with other packets. As a result, both parties must agree on a simulated communication path built on a stateless IP address. This matching is called a join. This is basically establishing relationships between packages in a chain.

+4
source

Routers are not aware of the connection. A connection is a logical TCP concept that adds packet delivery reliability that UDP lacks. However, routers are only interested in IP, TCP, UDP, everything else is layers on top of IP. Routers route IP packets without regard to the high protocols they contain.

+2
source

two definitions from Wikipedia seem clear to me

In telecommunications, a connectionless connection describes a connection between two network endpoints at which a message can be sent from one endpoint to another without prior agreement. a device at one end of the communication transmits data to the other, without first ensuring that the recipient is available and ready to receive the data. The device sending the message simply sends it to the intended recipient address.

...

A connection-oriented network protocol is one that provides data flow in the same order as after the first session was established.

I donโ€™t think I can improve these definitions, but let me try to explain this in terms of sockets, realizing that socket is the programming interface for TCP / UDP . In particular, if you program server sockets, say, in Java, you will notice how this type of TCP and UDP, connection-oriented and unrelated, affects the programming model.

In a TCP-based client-server application, before any data transfer is completed, it is necessary to establish a connection between the client socket and the server socket corresponding to this client socket. On the server, you will need to create a ServerSocket , and then call accept() to get the Socket matching the client connection. One such socket is created to communicate with each connection from any particular remote client (which is initiated by creating an instance of the Socket class). You can refer to this sample code for more information.

On the other hand, if you program UPD, your server socket is basically a DatagramSocket object that listens on the port and receives all datagrams sent to it, and is also able to send datagrams back to any specific client socket. That is, one server socket serves all clients, because there is no end-to-end connection between any client connection and the server. (Note that the โ€œ serverSocket#accept() โ€ step is also not required.) In other words, each client and server can simply send datagrams without worrying about whether the other endpoint is ready to receive the datagrams or not. You can refer to this sample code for more information.

+2
source

All Articles