当前位置:网站首页>Network protocol: SCTP flow control transmission protocol

Network protocol: SCTP flow control transmission protocol

2022-04-23 19:06:00 InfoQ

brief introduction

Talk about network protocols , It must be inseparable from OSI(Open System Interconnection) The seven-tier model .  We generally focus on the layers above the network layer , such as IPV4 IPV6 The network layer ,TCP UDP Transport layer ,HTTP FTP Application layer, etc .

What I'm going to talk about today sctp agreement , The full name is Stream Control Transmission Protocol, Translated into Chinese is the flow control transmission protocol . By IETF stay RFC 4960 Proposed in .

Transport layer has been widely used TCP and UDP agreement , So why invent one SCTP What about the agreement? ?

Obviously SCTP The agreement is right TCP and UDP Promotion of agreement , To be specific SCTP The agreement provides both UDP The message oriented nature of the protocol , At the same time, it has TCP The reliability of the protocol 、 Functions of sequential transmission and congestion control , It also provides the function of multi host and redundant path , So as to improve elasticity and reliability .

This article will explain in detail SCTP Implementation principle and protocol details .

TCP What's wrong with

TCP What's wrong ?TCP Of course , We know UDP Is an unreliable means of message transmission , and TCP It is a reliable way of message transmission .

UDP and TCP It has been used in a very wide range of application scenarios . But a product or agreement cannot be perfect , There must be some shortcomings , Let's see TCP What are the shortcomings of .

TCP and UDP The biggest difference is TCP Is reliable , in other words TCP Provided through  Internet  A method of reliably transmitting data .

however TCP In order to ensure reliable data transmission , There are some restrictions on transmission .

for instance ,TCP In order to ensure the reliability of data transmission , The sequence of data transmission needs to be strictly required . For example, a data packet is divided into three parts, labeled A,B,C. So for the receiver , You must first accept the packet A, And then there was B and C. If you receive it first B, Then the receiver will need to send and resend packets .

In this case of strict packet order , It may cause unnecessary data delay and message blocking .

because TCP It's data flow oriented , To mark different records in the data stream ,TCP The data in the needs to add some additional marks or codes to distinguish the records .

in addition , In order to improve transmission efficiency , Avoid sending multiple small packets ,TCP It may also be optimized , In other words, wait for multiple small packets to merge them into a large packet . If you don't want such optimization , So you need to TCP Set... In the packet PSH sign , Make it clear that the request is a transmission request without delay .

Last TCP It's also easy to receive DOS(denial-of-service) attack .

sctp Characteristics

since TCP There are many shortcomings , So new SCTP What are the characteristics of the agreement ?

SCTP There are two main characteristics , The first characteristic is Message-based, in other words SCTP It's message oriented .SCTP The transmission is a series of messages , A message is a set of bytes .

by comparison TCP The transmission is a byte stream .

SCTP A message in can be split into multiple data blocks , All data in each data block comes from the same user . When these data need to be in IP When transmitting in ,SCTP These packets will be packaged into SCTP packets, Every SCTP packet, All contain a packet header, Control blocks can also be included if necessary , Finally, the data block is followed .

How to understand TCP Bao He SCTP The difference between the bags ?

for instance , When the client uses TCP When the protocol sends multiple messages to the server , If the message is very short , In order to improve transmission efficiency ,TCP These small data with different functions may be put into the same TCP In bag . In the process of receiving from the server, this is also collected at one time TCP All data in the package , Then it's up to the application itself TCP Split the underlying data in the package .

about SCTP Come on , One SCTP A package can contain multiple data chunks, Different data chunks Can contain different messages from different users , because SCTP The package has distinguished between different messages , Therefore, it is relatively easy to read from the server .

Here's a SCTP The basic structure of the package :

null
As can be seen from the above figure , The blue part in the front 12 Bytes are SCTP The head of the bag , The first two bytes are the source port number , The next two bytes are the target port number , then 4 The first byte is the verification mark , final 4 The first one is directly the check bit , in total 12 Bytes .

header The back is data chunks, That is, data blocks , Every chunk Both contain a type bit ,flags Bits and length bits , Followed by chunk Specific data .

SCTP Another feature of is multi-streaming, Multi stream means SCTP It can transmit multiple independent data streams in parallel , For example, when visiting a web page, you can transmit the image and text of the web page at the same time .

Why can this be done ? This is also by SCTP The structure of the packet , We can see SCTP A packet can contain multiple data chunks, these data chunks It can contain data from different data streams , So message oriented SCTP It can realize the function of parallel transmission of data from different data sources .

SCTP The other feature of the Multihoming,Multihoming yes multiple+homing A compound word of , It literally means multiple home.

What does that mean ?

We know that TCP Agreement for , There is only one client and server , It belongs to the case of one-to-one connection , If this connects both ends and either IP Or the port cannot , So the whole TCP Your connection crashed .

that TCP Can it develop into something like LSB What about the load balancing mode ? If one IP Can not be , Automatic reconnection to standby IP Address .

SCTP Namely TCP Upgraded version of the protocol , It is optimized in terms of enhancing reliability .

To be specific , Every SCTP All nodes will use the heartbeat mechanism to regularly check the master node of the remote node IP Address and spare redundancy IP Accessibility of address . stay SCTP A node in can bind multiple nodes IP Address .

SCTP The node will confirm the specific access information according to the heartbeat return value received from the remote node .

Because the number of client nodes and server nodes may be different , therefore SCTP Can be divided into symmetrical multihoming And asymmetric multihoming.

The following three figures are symmetrical multihoming And two asymmetric multihoming The situation of :

null
null
null
Last ,SCTP The security of has also been improved . Compare with TCP Compared with three handshakes ,SCTP With four handshakes .

TCP Three handshakes can lead to SYN attack .

What is? SYN Attack ? Let's review TCP The three handshake process of mobile phone , First the client sends one SYN A Request to the server , The server receives this SYN After the request , Will SYN Request cache , And back to the client SYN B,ACK A+1,  After the client receives the reply , check ACK Value , And then send... Again ACK B+1 To the server side . Server side received B+1 After the request , Finally confirm the identity of the client , Connection established .

In the above process, because the server side needs to cache TCP Client's SYN news , So if the server receives a lot SYN If it's news , That's why SYN attack .

By contrast ,SCTP After receiving the connection request from the client , Memory is not immediately allocated and cached , It's back to a COOKIE To the client . When the client requests again , You need to bring this COOKIE Information , Server side through COOKIE check , After confirming the identity of the client , Will finally establish a connection . To avoid TCP Of SYN attack .

summary

in summary ,SCTP It can ensure the reliable transmission of orderly and countless data streams , Can support Multihoming, Each node can contain multiple nodes IP Address , Thus, transparent failover between redundant network paths can be realized . And improved the verification and confirmation mechanism , Can prevent SYN attack .

SCTP It's a very good agreement . For common operating systems , In a particular version, a pair of SCTP Support for . For example linux in , kernel 2.4 Both versions support SCTP agreement .

If in windows perhaps MAC On , Additional third-party drivers are required , among windows The driver is called SctpDrv kernel driver,MAC The driver on the is called SCTP Network Kernel Extension for Mac OS X.

This article has been included in  
http://www.flydean.com/21-sctp/
The most popular interpretation , The deepest dry goods , The most concise tutorial , There are so many tricks you don't know about waiting for you to discover !
Welcome to my official account. :「 Program those things 」, Know technology , Know you better !

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231904213812.html