Sticky pack issues, and how to invoke operating system commands in Python

Source: Internet
Author: User

A. New module ' subprocess '

review: Invoking system commands in the OS moduleImportOSF= Os.popen ('dir')Print(F.read ()) The result above is the same as the following notationImportSUBPROCESSR= subprocess. Popen ('ls', Shell=true,stdout=subprocess. Pipe,stderr=subprocess. PIPE)#subprocess. Popen (Cmd,shell=true,subprocess.stdout,subprocess.stderr)#cmd: Represents a System command#Shell = True Indicates that this command is a system command that tells the operating system to execute CMD as a system command#stdout is a pipe that is used to save results after a system command has been executed#stderr is a pipe used to hold error results after a system command has been executedstdout = R.stdout.read (). Decode ('GBK') stderr= R.stderr.read (). Decode ('GBK')Print('the correct return result:', stdout)Print('incorrect return result:', stderr)Print('incorrect return result:', stderr)

Two. Sticky packet problem (only TCP protocol will send sticky packets, UDP will not occur)

EX: Sending data , the receiver does not know how to receive , resulting in a data chaos phenomenon

1. The package mechanism (Nagle algorithm): The data that is sent multiple times and with smaller intervals is packaged into a single piece of data transfer .

2. Unpacking mechanism: Another mechanism is the unpacking mechanism , on the sending side , because the MTU limit of the network card , will be larger than the MTU Limit  of Data , split, split into multiple small data , for transmission . When transferred to the operating system layer of the target host, multiple small data are re-merged into the original data

 for sending data using the UDP protocol, how much is the one-time transceiver size appropriate? UDP does not occur sticky packets, the UDP protocol this layer to the size of the first time    to send and receive data is:65535-ip Baotou (8)-UDP packet packet = 65507 station at the data link layer, because the network card MTU is generally limited to 1500, So for the data link layer,
The size of a single transmit and receive data is limited to 1500-ip Baotou (8) = 1472 : if SendTo (num) > 65507 Error 1472 < num < 65507 will be unpacking at the data link layer, and UDP itself is not a reliable protocol, so once the packet is split, the resulting multiple small packets in the network transmission, if you lose any one, then this data transfer failed < 1472 is a more ideal state

Sticky pack issues, and how to invoke operating system commands in Python

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.