Data transfer protocols TCP and UDP. Transport Protocols - UDP

UDP APPLICATIONS

UDP, among many other applications, also supports Trivial File Transfer Protocol (TFTP), Simple Network Management Protocol (SNMP), and Routing Information Protocol (RIP).
TFTP (Simple File Transfer Protocol). It is mainly used to copy and install the operating system on a computer from a file server,

TFTP. TFTP is a smaller application than File Transfer Protocol (FTP). Typically, TFTP is used on networks for simple file transfer. TFTP includes its own error and sequential control mechanism and therefore does not need additional services at the transport layer.

SNMP (Simple Network Management Protocol) monitors and manages networks and devices attached to them, and collects information about network performance. SNMP sends protocol block messages that enable network management software to monitor devices on the network.

RIP (Routing Information Protocol) is an internal routing protocol, which means it is used within an organization, but not on the Internet.

TCP APPLICATIONS

TCP, among many other applications, also supports FTP, Telnet, and Simple Mail Transfer Protocol (SMTP).

FTP (File Transfer Protocol) is a full-featured application that is used to copy files using a running client application on one computer linked to an FTP server application on another remote computer. With this application, files can be received and sent.

Telnet allows you to establish terminal sessions with a remote device, usually a UNIX host, router, or switch. This gives the network administrator the ability to control the network device as if it were in close proximity, using the computer's serial port for control. Telnet's usefulness is limited to systems that use character mode command syntax. Telnet does not support managing the user's graphical environment.

SMTP (Simple Mail Transfer Protocol) is a mail transfer protocol for the Internet. It supports the transfer of e-mail messages between mail clients and mail servers.

WELL KNOWN PORTS
Well-known ports are assigned by the IANA and range from 1023 and below. They are assigned to applications that are essential for the Internet.

REGISTERED PORTS
Registered ports are cataloged by IANA and range from 1024 to 49151. These ports are used by licensed applications such as Lotus Mail.

DYNAMICALLY ASSIGNABLE PORTS
The dynamically assigned ports are assigned numbers from 49152 to 65535. The numbers for these ports are assigned dynamically for the duration of a specific session.

TCP and UDP protocols

TCP- Transmission Control Protocol

Connection-oriented communication can use reliable communication, for which the Layer 4 protocol sends acknowledgments to receive data and requests retransmission if no data is received or is corrupted. TCP uses just this kind of reliable communication. TCP is used in application protocols such as HTTP, FTP, SMTP, and Telnet.

TCP requires that a connection be opened before sending a message. The server application must execute the so-called passive open to create a connection with a known port number, and instead of sending a call to the network, the server waits for incoming requests. The client application should execute active open by sending a sync sequence number (SYN) to the server application that identifies the connection. The client application can use a dynamic port number as the local port.

The server should send an acknowledgment (ACK) to the client along with the server sequence number (SYN). In turn, the client answers with ACK, and the connection is established.

After that, the process of sending and receiving messages can begin. When a message is received, an ACK message is always sent in response. If the timeout expires before the sender receives the ACK, the message is placed on the retransmission queue.

The TCP header fields are listed in the following table:

TCP header
Field Length Description
Source port 2 bytes Source port number
Port of destination 2 bytes Destination port number
Serial number 4 bytes The sequence number is generated by the source and used by the destination to reorder packets to create the original message and send an acknowledgment to the source.
Confirmation number 4 bytes If the ACK bit of the Control field is set, this field contains the next expected sequence number.
Data offset 4 bits Information about the beginning of a data packet.
Reserve 6 bits Reserved for future use.
Control 6 bits The control bits contain flags indicating whether the acknowledgment (ACK), urgency (URG) fields are correct, whether the connection should be reset (RST), whether a sync serial number (SYN) was sent, and so on.
Window size 2 bytes This field indicates the size of the receive buffer. Using confirmation messages, the recipient can inform the sender of the maximum amount of data that he can send.
Check sum 2 bytes Header and data checksum; it determines whether the packet has been corrupted.
Urgency pointer 2 bytes In this field, the target device receives information about the urgency of the data.
Options variable Optional values ​​that are specified as needed.
Addition variable So many zeros are added to the padding field so that the header ends at a 32-bit boundary.

TCP is a complex, time-consuming protocol due to its connection establishment mechanism, but it takes care of the guaranteed delivery of packets, eliminating the need to include this functionality in the application protocol.

TCP has a built-in reliable delivery capability. If the message was not sent correctly, we will receive an error message. TCP is defined in RFC 793.

UDP - User Datagram Protocol

Unlike TCP, UDP is a very fast protocol because it defines the smallest mechanism required to transfer data. Of course, it has some disadvantages. Messages arrive in any order, and whichever is sent first may be received last. Delivery of UDP messages is not guaranteed at all, the message may be lost, and two copies of the same message may be received. The latter case occurs when two different routes are used to send messages to one address.

UDP does not require a connection to be opened and data can be sent as soon as it is prepared. UDP does not send acknowledgment messages, so data can be received or lost. If UDP requires reliable data transmission, it should be implemented in a higher layer protocol.

So what are the advantages of UDP, why would such an unreliable protocol be needed? To understand the reason for using UDP, one must distinguish between unicast, broadcast, and multicast.

Unidirectional (unicast) message is sent from one node to only one other node. This is also called point-to-point communication. TCP only supports unidirectional communication. If a server needs to communicate with multiple clients using TCP, each client must establish a connection, since messages can only be sent to single nodes.

Broadcast means that the message is sent to all hosts on the network. Multicast is an intermediate mechanism: messages are sent to selected groups of nodes.

UDP can be used for unidirectional communication if fast transmission is required, such as for delivering multimedia data, but the main advantages of UDP are in broadcast and multicast.

At the data link and network level of protocols TCP / IP packet, which relate to the main mechanism for the transfer of data blocks between countries and between networks, are the basis TCP / IP... They use the protocol stack, but they are not used directly in applications that run the protocol TCP / IP... In this article, we will look at two protocols that are used by applications: User Datagram Protocol (UDP) and Transmission Control Protocol (TCP).

User datagram protocol
The User Datagram Protocol is a very simple protocol. As well as IP, it is a reliable, connectionless protocol. You don't need to establish a connection to the host to communicate with it using UDP, and there is no mechanism to ensure the transmitted data.
Block of data transmitted using UDP called a datagram. UDP adds four 16-bit header fields (8 bytes) to the transmitted data. These fields are field length, checksum field, and source and destination port number. "Port", in this context, is the software of the port, not the hardware port.
The concept of a port number is common to both UDP and TCP... The port numbers determine which protocol module is sending (or receiving) data. Most protocols have standard ports that are commonly used for this. For example, Telnet usually uses port 23. Simple Mail Transfer Protocol (SMTP) uses port 25. Using standard port numbers allows clients to communicate with the server without first setting which port to use.
Port and protocol number in the header field IP duplicate each other to some extent, although protocol fields are not available for higher-level protocols. IP uses a protocol field to determine where data should be transferred to UDP or TCP modules. UDP or TCP use the port number to determine which application layer protocol should receive data.
Despite, UDP is not reliable, it is still a suitable choice for many applications. It is used by real-time applications such as streaming audio and video, where if data is lost it is better to do without it than send it again in order. It is also used by protocols such as Simple Network Management Protocol (SNMP).
Broadcast
UDP suitable for information broadcasting, since it does not require connection to an open connection. The targets of a broadcast message are determined by the sender, to the specified destination IP address. UDP datagrams with destination IP are all binary 255.255.255.255) and will be received by every host on the local network. Pay attention to the word local: datagrams with this address will not be accepted by the router to the Internet.
Broadcasts can be directed to specific networks. UDP datagrams from the host and subnet, the portions of the IP address set as binary are broadcast to all hosts on all subnets of the network that corresponds to the clean portion of the IP address. If only the receiving side (in other words, all the bits that are zero in the subnet mask) are set to binary, then the broadcast is limited to all hosts on the subnet that matches the rest of the address.
Multicast is used to transmit data in a group of hosts that have expressed a desire to receive it. Multicast UDP the datagram has a destination address in which the first four bits are 1110, provided addresses are in the range 224.xxx to 239.xxx The remaining bits of the address are used to designate the multicast group. It is more like a radio or TV channel. So, for example, 224.0.1.1 is used for the NTP protocol. If TCP / IP applications want to receive a multicast message, they must join the appropriate multicast group, which it does by passing the address of the group onto the protocol stack.
Broadcasting essentially filters the transmission. Multicaster does not consider individual messages for each host that joins the group. Instead, messages are broadcast, and the drivers on each host decide whether to ignore them or pass the contents to the protocol stack.
This means that multicast messages must be broadcast all over the Internet, since the multicaster does not know which hosts want to receive messages. Fortunately, this is not necessary. IP uses a protocol called Internet Group Management Protocol (IGMP) to tell routers which hosts want to receive multicast messages, so messages are sent only to where they are needed.
Transmission control protocol
Transmission Control Protocol is a transport layer protocol used by most Internet applications such as Telnet, FTP, and HTTP. It is a connection-oriented protocol. This means that two computers are one client, the other is a server, and a connection must be established between them before data can be transferred between them.
TCP provides reliability. Application that uses TCP knows that he is sending data received on the other end, and that he received it correctly. TCP uses checksums on both headers and data. When receiving data, TCP sends confirmation back to the sender. If the sender does not receive confirmation within a certain period of time, the data is re-sent.
TCP includes mechanisms for ensuring data arrives in reverse order in the order in which it was sent. It also implements flow control so that the sender cannot overwhelm the receiver of the data.
TCP transmits data using IP in blocks called segments. The length of the segment is determined by the protocol. In addition to the IP header, each segment consists of 20 bytes of header. Heading TCP starts with a 16-bit source and port number destination field. As well as UDP, these fields define the level of the application, which is also aimed at receiving data. The IP address and port number, taken together, uniquely identify the services running on the host, and the pair is known as the socket.
Next in the header is a 32-bit sequence number. This number defines the position in the data stream that should occupy the first byte of data in the segment. Serial number TCP keeps the data flow in the correct order, although segments can be derived from sequence.
The next field is a 32-bit field that is used to send back to the sender that the data was received correctly. If the ACK flag, which it usually is, then this field contains the position of the next data byte that the sender of the segment expects to receive.
V TCP there is no need for each data segment to be recognized. The value in the confirmation field is interpreted as "all data so far received by OK". This saves bandwidth when all data is routed one way, reducing the need for segment recognition. If data is sent in both directions at the same time, as in full duplex communication, then stamps are not associated with costs, since the one-way data segment may contain acknowledgment for data sent differently.
Further in the header is a 16-bit field containing the length of the header and flags. TCP headers can contain additional fields, so the length can vary from 20 to 60 bytes. Flags: URG, ACK (which we already mentioned), PSH, RST, SYN and FIN. We'll look at some of the other flags later.
The header contains a field called the window size, which gives the number of bytes that the receiver can accept. There is also a 16-bit checksum covering both header and data. Finally (before additional data) there is a field called "urgency indicator". When the URG flag is set, this value is interpreted as a sequence number offset. It defines the beginning of data in the stream that must be processed urgently. This data is often referred to as out-of-band data. An example of its use is when the user presses the break key to abort the exit from the program during a Telnet session.

UDP uses a simple transmission model, with no implicit handshakes, to ensure reliability, ordering, or data integrity. Thus, UDP provides an unreliable service, and datagrams may arrive out of order, duplicate, or disappear altogether. UDP implies that error checking and fixing is either unnecessary or must be performed in the application. Time-sensitive applications often use UDP because dropping packets is preferable to waiting for delayed packets, which may not be possible in real-time systems. If it is necessary to correct errors at the network layer of the interface, the application can use TCP or SCTP designed for this purpose.

The nature of UDP as a stateless protocol is also useful for servers responding to small requests from a large number of clients, such as DNS and streaming media applications such as IPTV, Voice over IP, IP tunneling protocols, and many online games.

Service ports

UDP does not provide any guarantees of message delivery for the upper layer protocol and does not preserve the state of sent messages. For this reason, UDP is sometimes referred to as the Unreliable Datagram Protocol.

Before calculating the checksum, the UDP message is padded with zero bits at the end to a multiple of 16 bits (the pseudo header and padding zero bits are not sent with the message). Checksum field in UDP header during checksum calculation sent the message is received at zero.

To calculate the checksum, the pseudo-header and UDP message are split into words (1 word = 2 bytes (octets) = 16 bits). Then the one's complement sum is calculated for the sum of all the one's complement words. The result is written into the corresponding field in the UDP header.

A checksum value of zero is reserved and means that the datagram has no checksum. If the calculated checksum is zero, the field is filled with binary ones.

Upon receipt of the message, the recipient reads the checksum again (already taking into account the checksum field), and if the result is a binary number of sixteen units (that is, 0xffff), then the checksum is considered to have converged. If the sum does not add up (the data was corrupted in transit), the datagram is destroyed.

Example of calculating checksum

For example, let's calculate the checksum of several 16-bit words: 0x398a, 0xf802, 0x14b2, 0xc281. Find their sum with bit's complement.
0x398a + 0xf802 = 0x1318c → 0x318d
0x318d + 0x14b2 = 0x0463f → 0x463f
0x463f + 0xc281 = 0x108c0 → 0x08c1
Now we find the bitwise complement to one of the result obtained:

0x08c1 = 0000 1000 1100 0001 → 1111 0111 0011 1110 = 0xf73e or, otherwise - 0xffff - 0x08c1 = 0xf73e. This is the desired checksum.

When calculating the checksum, a pseudo-header is again used, simulating a real IPv6 header:

Bits 0 – 7 8 – 15 16 – 23 24 – 31
0 Source address
32
64
96
128 Address of the recipient
160
192
224
256 UDP Length
288 Zeros Next heading
320 Source port Recipient port
352 Length Check sum
384+
Data

The source address is the same as in the IPv6 header. Recipient address - final recipient; if the IPv6 packet does not contain the routing header, then this will be the destination address from the IPv6 header, otherwise, at the start node, it will be the address of the last element of the routing header, and at the destination node, the destination address from IPv6 header. The Next Header value is equal to the protocol value - 17 for UDP. UDP Length - The length of the UDP header and data.

Reliability and overload solutions

Due to a lack of reliability, UDP applications must be prepared for some loss, error, and duplication. Some of them (for example, TFTP) can add rudimentary mechanisms for ensuring reliability at the application layer if necessary.

But more often such mechanisms are not used by UDP applications and even interfere with them. Streaming media, real-time multiplayer gaming, and VoIP are examples of applications that often use UDP. In these specific applications, packet loss is usually not a big problem. If the application requires a high level of reliability, then another protocol (TCP) or erasure codes can be used.

A bigger potential problem is that, unlike TCP, UDP-based applications do not necessarily have good congestion control and avoidance mechanisms. Congestion-sensitive UDP applications that consume a significant portion of the available bandwidth can compromise the stability of the Internet.

Networking mechanisms were designed to minimize the potential effects of congestion from uncontrolled, high-speed loads. Network elements such as routers that use packet queuing and discard techniques are often the only available tool to slow down excess UDP traffic. DCCP (Datagram Congestion Control Protocol) is designed as a partial solution to this potential problem by adding congestion control mechanisms to the end host for high-speed UDP streams like streaming media.

Applications

Numerous key Internet applications use UDP, including DNS (where requests must be fast and consist of only one request followed by one response packet), Simple Network Management Protocol (SNMP), Routing Information Protocol (RIP), Protocol Dynamic Host Configuration (DHCP).

Voice and video traffic is usually carried over UDP. Real-time video and audio streaming protocols are designed to handle random packet loss so that quality is only marginally degraded instead of large retransmission delays for lost packets. Since both TCP and UDP share the same network, many companies find that the recent increase in UDP traffic from these real-time applications is interfering with the performance of TCP applications such as databases or accounting. Since both business and real-time applications are important to companies, the development of quality solutions to the problem is viewed by some as a top priority.

Comparison of UDP and TCP

TCP is a connection-oriented protocol, which means that a handshake is required to establish a connection between two hosts. Once the connection is established, users can send data in both directions.

  • Reliability- TCP manages the acknowledgment, retransmission and timeout of messages. Numerous attempts are made to deliver the message. If it gets lost on the way, the server will re-request the lost part. In TCP, there is neither missing data nor (in the case of multiple timeouts) broken connections.
  • Orderliness- if two messages are sent in succession, the first message will reach the receiving application first. If chunks of data arrive in the wrong order, TCP sends out-of-order data to a buffer until all data can be ordered and passed to the application.
  • Heaviness- TCP needs three packets to establish a socket connection before sending data. TCP keeps track of reliability and congestion.
  • Streaming- the data is read as a stream of bytes, no special designations for message boundaries or segments are transmitted.

UDP is a simpler, message-based, connectionless protocol. These types of protocols do not establish a dedicated connection between two hosts. Communication is achieved by transferring information in one direction from source to destination without checking the readiness or status of the destination. However, the main advantage of UDP over TCP is Voice over IP (VoIP) applications, in which any "handshake" would interfere with good voice communications. In VoIP, end users are expected to provide any necessary confirmation of receipt of a message in real time.

  • Unreliable- when a message is sent, it is not known whether it will reach its destination - it may get lost along the way. There are no such concepts as acknowledgment, retransmission, timeout.
  • Disorder- if two messages are sent to the same recipient, then the order of their achievement of the goal cannot be predicted.
  • Lightness- no message ordering, no connection tracking, etc. It is a small transport layer developed over IP.
  • Datagrams- Packets are sent separately and are checked for integrity only if they have arrived. Packets have certain boundaries that are respected upon receipt, that is, a read operation on the receiving socket will return the message as it was originally sent.
  • No congestion control- UDP itself does not avoid congestion. For high-bandwidth applications, it is possible to cause congestion collapse unless they implement application-level controls.

RFC links

  • RFC 768 - Custom Datagram Protocol
  • RFC 2460 - Internet Protocol Specification Version 6 (IPv6)
  • RFC 2675 - IPv6 Jumbograms
  • RFC 4113 - Management Information Base for the UDP
  • RFC 5405 - Unicast UDP Usage Guidelines for Application Designers

see also

Links

  • Kurose, J. F .; Ross, K. W. (2010). Computer Networking: A Top-Down Approach (5th ed.). Boston, MA: Pearson Education. ISBN 978-0-13-136548-3.
  • Forouzan, B.A. (2000). TCP / IP: Protocol Suite, 1st ed. New Delhi, India: Tata McGraw-Hill Publishing Company Limited.
  • [email protected]"UDP Protocol Overview". Ipv6.com. Retrieved 17 August 2011.
  • Clark, M.P. (2003). Data Networks IP and the Internet, 1st ed. West Sussex, England: John Wiley & Sons Ltd.
  • Postel, J. (August 1980). RFC 768: User Datagram Protocol. Internet Engineering Task Force. Retrieved from http://tools.ietf.org/html/rfc768
  • Deering S. & Hinden R. (December 1998). RFC 2460: Internet Protocol, Version 6 (IPv6) Specification. Internet Engineering Task Force. Retrieved from http://tools.ietf.org/html/rfc2460
  • "The impact of UDP on Data Applications". Networkperformancedaily.com. Retrieved 17 August 2011.
  • D. Comer. Internet exchange using TCP / IP. Chapter 11. UDP protocol.

UDP (User Datagram Protocol) is a connectionless transport protocol for data transmission over IP networks. It is one of the simplest transport layer protocols of the OSI model. Its IP identifier is 0x11.

UDP is commonly used in applications such as streaming video and computer games, where packet loss is tolerated and re-query is difficult or not justified, or in request-response applications (for example, DNS queries), where creating a connection takes more resources than Resending. In fact, UDP functions are limited to multiplexing and demultiplexing operations, as well as a simple check for data errors. Thus, when using U DP, the application interacts almost directly with the IP network layer protocol.

UDP receives messages from the application layer, adds the source and destination port number fields to them for demultiplexing by the receiving side, as well as two other special fields, and transmits the received segment to the network layer. The network layer encloses the segment in a datagram and passes it "whenever possible" to the destination host. If the latter successfully receives the segment, UDP uses the destination port number field to forward the segment data to the correct process. Therefore, UDP is said to perform connectionless data transmission.

An example of an application layer protocol that uses UDP protocol services is DNS. When a DNS application generates a request, it creates a DNS message and sends it to UDP.


Comparison of UDP versus TCP protocols.

If the application requires confirmation of message delivery, it uses the protocol TCP... TCP breaks up a message into smaller chunks called segments. These segments are sequentially numbered and passed to the IP protocol, which then reassembles the packets. TCP keeps track of the number of segments sent to a given host by an application. If the sender does not receive an acknowledgment within a certain period of time, then TCP treats these segments as lost and retries them. Only the lost portion of the message is resubmitted, not the entire message.

TCP at the receiving host is responsible for reassembling the message segments and forwarding them to the appropriate application.

FTP and HTTP are examples of applications that use the TCP protocol to provide data delivery.

Protocol UDP performs non-guaranteed delivery of data and does not ask for confirmation from the recipient. UDP is the preferred protocol for streaming audio, video, and voice over IP (VoIP). Confirmation of delivery will only slow down the data transfer process, and re-delivery is undesirable. An example of using UDP is Internet radio.


ARP protocol. Application.

ARP(eng. Address Resolution Protocol- address determination protocol) is a low-level protocol used in computer networks, designed to determine the link-layer address from a known network-layer address. This protocol is most widely used due to the ubiquity of IP networks built on top of Ethernet, since in almost 100% of cases, this combination uses ARP. The protocol description was published in November 1982 in RFC 826. ARP was designed for the case of sending IP packets over an Ethernet segment. At the same time, the general principle proposed for ARP may have been used for other types of networks.

The ARP message types are ARP request and ARP reply. The sending system uses an ARP request to request the physical address of the receiving system. The response (the physical address of the recipient host) comes in the form of an ARP response.

Before transmitting a network layer packet over the Ethernet segment, the network stack checks the ARP cache to see if it has already registered the necessary information about the destination host. If there is no such entry in the ARP cache, then an ARP broadcast request is made. This request for devices on the network has the following meaning: "Does anyone know the physical address of a device with the following IP address?" When a recipient with this IP address receives this packet, he will have to answer: “Yes, this is my IP address. My physical address is as follows: ... ”The sender will then update its ARP cache and be able to transmit information to the recipient.

ARP cache entries can be static or dynamic. The example above describes dynamic cache entry. You can also create static entries in the ARP table.

ARP was originally developed not only for the IP protocol, but is now mainly used to match IP and MAC addresses.

Principle of operation

A node that needs to map an IP address to a local address generates an ARP request, inserts it into a data link protocol frame, specifying a known IP address in it, and broadcasts the request.

All hosts on the local network receive an ARP request and compare the IP address specified there with their own.

If they match, the host generates an ARP response, in which it specifies its IP address and its local address and sends it already directed, since the sender specifies its local address in the ARP request.