Chapter 13 Stream Control Transmission Protocol Objectives Upon completion you will be able to: Be able to name and understand the services offered by SCTP Understand SCTP s flow and error control and congestion control Be familiar with the fields in a SCTP segment Understand the phases in an SCTP association Understand the SCTP state transition diagram
Stream Control Transmission Protocol SCTP: Stream Control Transmission Protocol A new reliable, message-oriented transportlayer protocol H.323, SIP need a more sophisticated service than TCP can provide SCTP is proposed
Figure 13.1 TCP/IP protocol suite
Comparison of UDP, TCP and SCTP UDP Message-oriented A process delivers a message to UDP UDP conserve the message boundaries Each message is independent from each other Good for real-time or IP telephony Unreliable Lack congestion control and flow control Bad for real-time or IP telephony
Comparison of UDP, TCP and SCTP (Cont.) TCP Byte-oriented protocol Reliable Receives a message, store them as a stream of bytes and sends them in segments Has congestion control and flow control
Comparison of UDP, TCP and SCTP (Cont.) SCTP Combine the features of UDP and TCP Reliable message-oriented protocol Preserve the message boundaries Reliable Have congestion control and flow control
13.1 SCTP SERVICES We explain the services offered by SCTP to the application layer processes. The topics discussed in this section include: Process-to to-process Communication Multiple Streams Multihoming Full-Duplex Communication Connection-Oriented Service Reliable Service
Process-to-Process Communication SCTP uses well-known ports in the TCP Table 13.1 Some SCTP applications
Multiple Streams TCP is stream-oriented protocol Each TCP connection involves one single connection However, a loss at any point blocks the delivery of the rest of data Not allow in real-time data SCTP allows multistreamservice in each connection Called association in SCTP Similar to multiple lanes on a highway
Figure 13.2 Multiple-stream concept
Multihoming Multihomed host Connected to more than one physical address with multiple IP addresses However, a TCP connection involves one source and one destination Only one IP address is utilized per end SCTP supports multihomingservice Sending host and receiving host can define multiple IP addresses in each end for an association Good for fault-tolerant
Figure 13.3 Multihoming concept
Multihoming (Cont.) In current SCTP Only one pair of IP addresses can be chosen for normal communication The alternative is used if the main choice fails Thus, does not support load sharing between different paths An association in SCTP can involve multiple streams.
Full-Duplex Communication Like TCP, data can flow in both directions at the same time Thus, each SCTP has a sending buffer and a receiving buffer
Connection-Oriented Services SCTP is a connection-oriented service A connection is called an association in SCTP
Reliable Service SCTP is a reliable transport protocol Use an acknowledgment mechanism
13.2 SCTP FEATURES We discuss the general features of SCTP and then compare them with those of TCP. The topics discussed in this section include: Transmission Sequence Number (TSN) Stream Identifier (SI) Stream Sequence Number (SSN) Packets Acknowledgment Number Flow Control Error Control Congestion Control
Transmission Sequence Number (TSN) Unit of data in TCP is a byte Each byte has a sequence number Unit of data in SCTP is data chunk A transmission sequence number (TSN) is used to number the data chunks Each data chunk has a TSN in its header In SCTP, a data chunk is numbered using a TSN.
Stream Identifier (SI) Several streams in a SCTP association Each stream is identified using a stream identifier (SI) Each data chunk carries SI in its header Thus it can be properly placed in its belonging stream To distinguish between different streams, SCTP uses a SI.
Stream Sequence Number (SSN) SCTP defines each data chunk in each stream with a stream sequence number (SSN) With SI and SSN A data chunk can be delivered to the appropriate stream and in the proper order To distinguish between different data chunks belonging to the same stream, SCTP uses SSNs.
Packets In TCP, a segment carries data and control information Data are carried as a collection of bytes Control information is defined by six control flag in the header In SCTP Data are carried as data chunks Control information are carried as control chunks However, several control chunks and data chunks can be packed in a packet
Figure 13.4 Comparison between a TCP segment and an SCTP packet TCP has segments; SCTP has packets.
Difference Between SCTP Packets and TCP Segments Control information In TCP: part of the header In SCTP: in the control chunks Data In TCP: the data in a TCP segment treated as one entity In SCTP: an SCTP packet can carry several data chunks Each chunk can belong to different stream Option Part of a TCP segment Does not exist in an SCTP packet SCTP handles options by defining new chunk types
Difference Between SCTP Packets and TCP Segments (Cont.) Header Mandatory part of TCP header is 20 bytes General header in SCTP is 12 bytes, shorter since An SCTP sequence number (TSN) belongs to each data chunk and located in the chunk s header The ack. number and window size are part of each chunk No need for a header length in SCTP (fixed at 12 bytes) There are no options to make the length of header variable No need for an urgent pointer in SCTP (see later)
Difference Between SCTP Packets and TCP Segments (Cont.) Checksum TCP: 16 bits SCTP: 32 bits SCTP has a verification tag Used as an association identifier to define each association Does not exist in TCP IP address and port address define a connection However, SCTP support multihomeing
Difference Between SCTP Packets and TCP Segments (Cont.) An SCTP packet includes several data chunks TSNs, SIs, and SSNs define each data chunk TCP use sequence number to define the numbering of the first byte in the data Control chunks in SCTP never use a TSN, SI, or SSN number These three identifiers belong only to data chunk Not to the whole packet TCP consume one sequence number if a segment carry control information (SYN, FIN)
Data Chunk, Stream, and Packet An association may send many packets A packet may contain several chunks Chunks may belong to different streams Example, in the following slides Process sends 11 message with 3 streams First four message are in the first stream Second three message are in the first stream Last four message are in the first stream Assume each message fits into one data chunk Assume only 3 data chunks per packet
Figure 13.5 Packet, data chunks, and streams Data chunk in stream 0 (SI=0) are carried in first and part of second packet Data chunk in stream 1 (SI=1) are carried in first and part of second packet Data chunk in stream 2 (SI=2) are carried in first and part of second packet
Data Chunk, Stream, and Packet (Cont.) Data chunks are identified by three identifiers: TSN, SI, and SSN. TSN is a cumulative number identifying the association Used for flow control and error control SI defines the stream to which the chunk belongs SSN defines the chunk s order in a particular stream.
Acknowledgment Number In TCP Acknowledgment number are byte-oriented Refer to the sequence number Control information are acked using a sequence number and acknowledgment number E.g., SYN segment acked by an ACK segment SCTP Acknowledgment number are chunk-oriented Refer to the TSN Control information are carried by control chunks Do not need a TSN Acked by another control chunk of the appropriate type (some need no acknowledgment) There is no need for a sequence number or an acknowledgment number
Acknowledgment Number (Cont.) In SCTP, acknowledgment numbers are used to acknowledge only data chunks; control chunks are acknowledged by other control chunks if necessary.
13.3 PACKET FORMAT We show the format of a packet and different types of chunks. An SCTP packet has a mandatory general header and a set of blocks called chunks. There are two types of chunks: control chunks and data chunks. c The topics discussed in this section include: General Header Chunks
Packet Format An SCTP packet A mandatory general header A set of blocks called chunks Control chunk Control and maintain the association Data chunk Carry user data In an SCTP packet, control chunks come before data chunks.
Figure 13.6 SCTP packet format
General Header Goal Define the end points of each association Preserve the integrity of the contents of the packet including the header Format Source port number Destination port number
General Header (Cont.) Verification tag Match a packet to an associations Serve an identifier for the association Repeat in every packet during the association Separate verification used for each direction in the association Checksum
Chunks Chunks have the same layout First three fields are common Information field depends on the type of chunk Note Information section must be a multiple of 4 bytes or padding bytes are added
Chunks (Cont.) Format Type Define the type of chunk, see Table 13.2 Flag Length Define special flag that a particular chunk may need Each bit have different meaning depending on the type of chunk Define the total size of chunk, including the first three fields Note, the length of padding is not included in the length field E.g., if length is 17, the receiver knows three are 3 padding bytes
Table 13.2 Chunks
Data Chunk Type: 0 Flag U: unordered Signal unordered data and the value of stream sequence number is ignored SCTP allows unordered delivery B: beginning E: end Both define the position of a chunk in a message that is fragmented B=1, E=1, there is no fragmentation (first and last) The whole message is carried in one chunk B=1, E=0, it is the first fragment B=0, E=1, it is the last fragment B=0, E=0, it is the middelefragment
Figure 13.9 DATA chunk
Data Chunk (Cont.) Transmission sequence number (TSN) Define the transmission sequence number Initialized in an INIT chunk for one direction and in ININ_ACK chunk for another direction Stream Identifier (SI) Define each stream in an association All chunks in the same stream in one direction have the same SI
Data Chunk (Cont.) Protocol Identifier Used by application program to define the type of data Ignore by the SCTP layer User data Note No chunk can carry data belonging to more than one message But a message can be split into several chunks This field cannot be empty It must have at least one byte of user data The value of length field cannot be less than 17 If the data cannot end at a 32-bit boundary, padding is added
INIT Chunk INIT chunk: initiation chunk First chunk sent by an end point to establish an association Cannot carry other control or data chunks Format Type: 1 Flag: 0 ( no flags) Length: a minimum of 20 More if there are optional parameters
Figure 13.10 INIT chunk
INIT Chunk (Cont.) Initiation tag Define the value of the verification tag for packets sent in the opposite direction Example: node A starts an association with node B A define an initiation tag value used as the verification tag for all packets sent from B to A Thus, the verification tag field in INIT packet is 0 Since has not yet defined the tag Advertised receiver window credit Used in flow control Define the initial amount of data that the INIT sender can allow
INIT Chunk (Cont.) Outbound stream Define the number of streams that the initiator suggests in the outbound direction It may be reduced by the other end point Maximum inbound stream Define the maximum number of stream that the initiator can support in the inbound direction Maximum number and cannot be increased by the other end point
INIT Chunk (Cont.) Initial TSN Initialized the transmission sequence number (TSN) in the outbound direction Each data chunk has to have one TSN Variable-length parameters Optional parameters Define the IP address of sending end point The number of IP addresses the end point can support Preservation of the cookie state Support of explicit congestion notification (ECN)
INIT ACK Chunk Second chunk sent during association establishment Cannot carry other control or data chunks The fields in the main part are the same in INIT chunk However, a mandatory parameter is required Discussed later
Figure 13.11 INIT ACK chunk
COOKIE ECHO Chunk Third chunk send during association establishment The packet can also carry user data Figure 13.12 COOKIE ECHO chunk
COOKIE ACK Chunk Forth and last chunk sent during association establishment Can only carry user data Figure 13.13 COOKIE ACK
SACK Chunk SACK chunk: selective ACK chunk Acknowledge the receipt of data packets Cumulative TSN acknowledgement Define the TSN of the last data chunk received in sequence Advertised receiver window credit Updated value of the receiver window size Number of gap ACK blocks Define the number of gaps in the data chunk received after the cumulative TSN The gap defines the sequence of received chunks Not the missing chunks
Figure 13.14 SACK chunk
SACK Chunk (Cont.) Number of duplicates Define the number of duplicate chunks following the cumulative TSN Gap ACK block start offset For the gap block, give the starting TSN relative to the cumulative TSN Gap ACK block end offset For the gap block, give the ending TSN relative to the cumulative TSN Duplicate TSN For each duplicate chunk, give the TSN of the chunk relative to the cumulative TSN
HEARTBEAT and HEARTHEAT ACK Chunks Used to periodically probe the condition of an association An end point sends a HEARTBEAT chunk The peer responds with a HEARTBEAT ACK if it is alive Format Sender specific information In HEARBEAT: include the local time and the address of the sender In BEARTBEAT ACK: copied from HEARTBEAT without change
Figure 13.15 HEARTBEAT and HEARTBEAT ACK chunks
SHUTDOWN, SHUTDOWN ACK, And SHUTDOWN COMPLETE The three chunks used for closing an association
ERROR Sent when an end point find some error in a received packet See Table 13.3 However, does not imply the aborting of the association This require an ABORT chunk
Table 13.3 Errors
ABORT Sent when an end point finds a fatal error and needs to abort the association The error type are the same as those for the ERROR chunk (Table 13.3)
FORWARD TSN Inform the receiver to adjust its cummulative TSN Provide partial reliable service
13.4 AN SCTP ASSOCIATION SCTP, like TCP, is a connection-oriented oriented protocol. However, a connection in SCTP is called an association to emphasize multihoming The topics discussed in this section include: Association Establishment Data Transfer Association Termination Association Abortion
Association SCTP is connection-oriented However, a connection in SCTP is called an association
Association Establishment Four-way handshake Similar to TCP Server: passive open Be prepared to receive any association Client: active open Initiate the association establishment
Figure 13.19 Four-way handshaking
Four-Way Handshake 1. Client sends the fist packet that contains an INIT chunk Verification tag (VT) in the general header is 0 INIT tag No verification tag has yet been defined for this direction An initiation tag to be used for packet from the other direction (server to client) Initial TSN Define the initial TSN for this direction (client to server) Advertised receiver window credit Advertise a value of client s rwnd Normally, rwnd is advertised in a SACK chunk It is done here because the third and fourth packet (COOKIE ECHO and COOKIE ACK) can include DATA chunk
Four-Way Handshake (Cont.) 2. Server sends the second packet that contains an INIT ACK chunk Verification tag (VT) The initiation tag value in the INIT chunk (server to client) INIT tag An initiation tag to be used for packet from the other direction (client to server) Initial TSN Define the initial TSN for this direction (server to client) Advertised receiver window credit Set the server s rwnd Send a cookie that defines the state of the server at this moment
Four-Way Handshake (Cont.) 3. Client sends the third packet that includes a COOKIE ECHO chunk Echo, without change, the cookie sent by the server in INIT ACK chunk Data chunks can be included in this packet 4. Server sends the fourth packet that includes the COOKIE ACK chunk Acknowledge the receipt of the COOKIE ECHO chunk Data chunks can be included in this packet
Number of Packets Exchanged TCP Three-way handshaking SCTP Four-way handshaking SCTP might be less efficient However, SCTP allow the exchange of data in the third and fourth packet SCTP also provide better security against SYN denial-of-service attacks
Verification Tag In TCP A connection is identified by IP addresses and port numbers that contained in each segment Problems A attacker can send segments to a TCP server using randomly chosen source and destination port number Waste system resource, similar to SYN attack A delayed segment from a previous connection can show up in a new connection that uses the same source and destination port address
Verification Tag (Cont.) Solution in SCTP: A verification tag that is carried in all packet traveling in one direction in an association Thus, two verification tags identify as association Thus A blink attacker cannot inject a random packet Since it is not easy to carry the exact tag (1~2^32) A packet from an old association cannot show up in a new association Since verification tag would surely be different
Cookie SYN attack in TCP Since a TCP and other resources are allocated when a server receive a SYN segment Solution in SCTP Postpone the allocation of resource until the reception of third packet At this time, the IP address of the sender is verified However, the information received in the first packet must be saved until the third packet arrives But it cannot save the information in memory
Cookie (Cont.) Solution in SCTP (Cont.) Thus, SCTP pack the information and send it back to the addresses received in the first packet Called generating a cookie There are two situations If the sender of the first packet is an attacker Server cannot receive the third packet Cookie is lost and no resources are allocated If the sender of the first packet is an honest client It receives and second packet with cookie Send the third packet with cookie that no changes Server then allocate resource until receiving the third packets
Data Transfer SCTP: Support bidirectional data transfer Also support piggybacking TCP Receive message from a process as a stream of bytes Without recognizing any boundary between them A segment can carry parts of two message SCTP Recognize and maintains boundaries Each message is inserted into a DATA chunk or chunks if fragmented
Note: In SCTP, only DATA chunks consume TSNs; DATA chunks are the only chunks that are acknowledged.
Data Transfer (Cont.) In Fig. 13.20 The third packet contains the SACK chunk SCTP acknowledges the last in-order TSN received, not the next expected The acknowledgment defines the cumulative TSN, the TSN of the last DATA chunk received in order.
Figure 13.20 Simple data transfer
Multihoming Data Transfer SCTP allow both ends to define multiple IP addresses for communication One of these address is primary address Defined using association establishment But is determined by the other end A source defines the primary address for a destination Used for data transfer Rest are alternative addresses One of the alternative address is used if the primary is not available
MultistreamDelivery SCTP distinguish between data transfer and data delivery Data transfer: movement of data chunks between source and destination By TSN numbers Data delivery: deliver data chunks to the appropriate position in their belonging stream Controlled by SI and SSN
MultistreamDelivery (Cont.) SCTP support two types of data delivery Ordered (default) Unordered Note: By SSN (stream sequence number) to define their order in a stream Set U flag and ignore the SSN value TSN: used in a direction of an association However, a connection may have many streams By SI and SSN
Fragmentation SCTP fragment message to conform to the maximum transmit unit (MTU) size along a particular routed path Avoid the performance degradation when IP routers have to perform fragmentation
Fragmentation (Cont.) If the total size of a message exceeds MTU, the message needs to be fragmented However, the total size means the size of an IP datagram How to estimate? (since we are in layer 4) Can be determined by adding the following components Size of the message Data chunk header If piggybacked with SACK, add SACK chunks SCTP general header IP header
Fragmentation (Cont.) Fragmentation Break the message into smaller fragments A DATA chunk header is added to each fragment Each with a different but sequent TSN All DATA chunk header carries The same stream identifier (SI) The same stream sequence number (SSN) The same protocol identifier (defined by application) The same U flag Assign the appropriate B and E flags First fragment: 10 Middle fragment: 00 End fragment: 01
Fragmentation (Cont.) Reassembly If B/E = 11, no fragmented Else Find all chunks with the same SI and SSN Use TSN to determine their order in a message The number of fragment can be determined by the TSN number of the first and last fragments
Association Termination Like TCP, both ends can close the association However, SCTP does not allow a halfclosed association
Figure 13.21 Association termination
Association Abortion
13.5 STATE TRANSITION DIAGRAM To keep track of all the different events happening during association establishment, association termination, and data transfer, the SCTP S software, like TCP, is implemented as a finite state machine. The topics discussed in this section include: Scenarios Simultaneous Close
13.6 FLOW CONTROL Flow control in SCTP is similar to that in TCP. In SCTP, we need to handle two units of data, the byte and the chunk. The topics discussed in this section include: Receiver Site Sender Site A Scenario
Flow Control In SCTP, we need to handle two unit of data The byte and the chunk The rwndand cwndare expressed in bytes The value of TSN and acknowledgement are expressed in chunks SCTP also uses byte-oriented window for flow control
Receiver Site Hold three variables cumtsn: Hold the last TSN received winsize Hold the available buffer size lastack Hold the last accumulative acknowledgment
Receiver Site (Cont.) 1. When the site receives a data chunk Subtract the size of the chunk from winsize TSN number of the chunk is stored in the cumtsn variable 2. When the process reads a chunk Add the size of removed chunk to winsize 3. When the receiver sends a SACK Check the value of lastack If less than cumtsn Send a ACK with cumulative TSN number equal to the cumtsn The advertised window size is set to winsize
Sender Site Hold three variables curtsn Refer to the next chunk to be sent rwnd Hold the last value advertised by the receiver intransit Hold the number of bytes in transit, byte sent but not yet acknowledged Have been sent Ready to be sent
Sender Site (Cont.) A chunk pointed by curtsn can be sent If its size of less than or equal to (rwnd-intransit) When a SACK is received The chunks with a TSN less than or equal to the cumulative TSN in SACK are removed from queue intransitis reduced by the total size of discarded chunks rwnd is update with the advertised window value in SACK
A Scenario See the Fig. 13.29, at the beginning rwnd at sender = 2000, winsizeat receiver = 2000 Advertise during association establishment Assume each data chunk is 1000 bytes
Figure 13.29 Flow control scenario
13.7 ERROR CONTROL SCTP uses a SACK chunk to report the state of the receiver buffer r to the sender. Each implementation uses a different set of entities and timers for the receiver and sender sites. The topics discussed in this section include: Receiver Site Sender Site Sending Data Chunks Generating SACK Chunks
Receiver Site In Fig. 13.30 The last ack. was for data chunk 20 Receiver stores all arriving chunks in a queue Leave space for any missing chunks Discard duplicate message SACK includes The TSN numbers for out of order chunks Relative to the cumulative TSN The TSN number for duplicate data chunks
Figure 13.30 Error control, receiver site
Sender Site In Fig. 13.31 There are two queues at the sender site A sending queue and a retransmission queue Assume each data chunk is 100 bytes 1400 bytes (TSN=23~TSN=36) are transmitted intranmit = 1400 When a packet is sent, one retranmission timer start for that packet (all data chunks in that packet) Chunks in a packet is moved to the retransmission queue When the retransmission timer for a packet expires When four duplicate SACK arrives that declare a packet as missing i.e., fast retransmission as discussed in TCP
Figure 13.31 Error control, sender site
Sender Site (Cont.) The chunks in the retransmission queue have priority The next time the sender sends is chunk 21 from retransmission queue Assume the SACK in Fig. 13.30 arrives at the sender in Fig. 13.31 Fig. 13.32 shows the new state
Figure 13.32 New state at the sender site after receiving a SACK chunk Should be gray
Sender Site (Cont.) All chunks having a TSN equal to or less that the cumtsn in the SACK Removed from the sending queue or retransmission queue Check 21 and 22 are removed from the retransmission queue Check 23 are removed from the sending queue Remove all chunks from the sending queue that are declared in the gap blocks Chunks 26 to 28 and chunks 31 to 34 are removed The list of duplicate chunks does not have any effect The value of rwnd is changed to 1000 As advertised in the SACK chunk
Sender Site (Cont.) Assume the retransmission timer for packet that carried chunks 24 and 25 has expired Move to retransmission queue A new retransmission timer is set (by the exponential backoffin TCP) The value of intransit is 400 4 chunks are now in transmit Note, the chunks in the retransmission queue are not counted They are assumed lost, not in transmit
Retransmission SCTP, like TCP, employs two strategies Retransmission timers The RTO (retransmission time-out) and RTT are calculated as in TCP Note, If host is multihoming Separate RTT and RTO must be calculated and kept for each path Receiving four SACK with the same missing chunks Receive four consecutive duplicate SACK whose gap ack information indicate some missing chunks Invoke fast retransmission as TCP
Generating SACK Chunks Rules for generating SCTP SACK chunks are similar to the rules for acknowledgment in TCP Rules 1. When an end sends a DATA chunk to the other end Must include a SACK chunk advertising the receipt of unacknowledged DATA chunks 2. When an end receives a packet containing data, but has no data to send Need to acknowledge the receipt of the packet within a specified time (usually 500 ms)
Generating SACK Chunks (Cont.) Rules (Cont.) 3. An end must send at least one SACK for every other packet it receives The rule overrides the second rule 4. When a packet arrives with out-of-order data chunks Need to immediately send a SACK chunk 5. When an end receive a packet with duplicate DATA chunk and no new DATA chunk The duplicate data chunks must be reported immediately with a SACK chunk
13.8 CONGESTION CONTROL SCTP uses the same strategies for congestion control as TCP. SCTP P uses slow start, congestion avoidance,, and congestion detection phases. SCTP also uses fast retransmission and fast recovery. The topics discussed in this section include: Congestion Control and Multihoming Explicit Congestion Notification
Congestion Control and Multihoming Like TCP But since SCTP is multihoming Each IP address must be maintained with a different value of rwnd
Explicit Congestion Notification Explicit Congestion Notification (ECN) Enable a receiver to explicitly inform the sender of any congestion experience in the network Indication of probable congestion A receiver encounter many delayed or lost packets Beyond the scope of this book