Out-of-band data in Linux programming

Source: Internet
Author: User
Tags ftp socket

Defining Out-of-band Data

Imagine being lined up in the bank waiting to process their bills. Everyone in this team will eventually move to the front and be served by a cashier. Now imagine a walk into the bank, over the team, and then a gun to the cashier. This can be considered as out-of-band data. The robber crossed the line because the gun gave him the power to override the crowd. The teller would also concentrate on the robber because he knew the current situation was urgent.

In turn, Out-of-band data on a connected flow-sleeve interface works like this. Typically, data is streamed from one end of the connection to the other, and all bytes of data are considered to be sorted precisely. Late-written bytes will never arrive earlier than the byte that was first written. However, the set interface API provides some practical programs, which can make a series of data unimpeded before the usual data arrives at the receiving end. This is known as sending Out-of-band data.

Technically, a TCP stream may not send out-of-band data. What he supports is a conceptual emergency data that is mapped to the interface API as Out-of-band data. This brings a lot of restrictions, which we'll discuss later.

Although we can immediately enjoy the benefits of crossing the entire team in the bank, we will also recognize that the use of guns to achieve this goal is antisocial behavior. A TCP flow often wants to send data bytes in a perfect queue, so random sending of data seems to contradict the concept of streaming. So why do you want to provide a nested interface for Out-of-band data?

Perhaps we have realized that sometimes the data will become urgent in a certain way. A streaming socket interface will have a large number of data queues waiting to be sent to the network. At the remote endpoint, there is also a large number of data that has been received but not yet read by the program. If the sending client needs to cancel a request that has been written to the server for some reason, he needs to send an urgent request to the server for an identity cancellation. If you fail to send a cancellation request to a remote server, you waste the server's resources needlessly.

An example of an actual program using Out-of-band data is the TELNET,RLOGIN,FTP command. The first two programs send the abort character as emergency data to the remote end. This allows the remote side to flush all unhandled inputs and discard all unsent terminal outputs. This quickly interrupts a running process that sends a large amount of data to our screen. The FTP command uses Out-of-band data to interrupt the transmission of a file.

Sleeve interface and Out-of-band data

It is important to re-emphasize that the socket interface itself is not a limiting factor. The concept of Out-of-band data is actually mapped to the emergency data pattern of TCP/IP traffic. Today, TCP flows are important for the network, and in this chapter we focus only on the use of Out-of-band data to accommodate TCP emergency data.

Change in the implementation

Unfortunately, the implementation of TCP has two different interpretations of how the emergency data is handled. These distinctions will be discussed in detail later in this chapter. These different explanations are:

RFC793 explanation of TCP emergency pointer

BSD interpretation of TCP emergency pointer

There is now an equally divided state, because the original TCP specification allows two interpretations. Thus, a "host needs" RFC identifies the correct explanation. However, most implementations are based on the BSD source, and today the BSD approach is a common usage. From the perspective of supporting both interpretations, Linux is in a split state. However, Linux defaults to using BSD interpretation.

Now we pause to detect a current setting for our Linux system. This determines whether the example of our chapter can produce the same result.

$ Cat/proc/sys/net/ipv4/tcp_stdurg

0

$

The output shown here is 0. This represents the current starting up of the BSD interpretation. If we get other output results (for example, 1), then if we want to get the same result as the example in this chapter, we should change it to 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.