SCTP introduction

   Richard Xiong
      2013/2/8
Motivations
• Provide reliable transfer without sequence
  maintenance.
• The stream-oriented nature of TCP is
  often an inconvenience. SCTP provides
  message based transfer.
• TCP is relatively vulnerable to denial-of-
  service attacks, such as SYN attacks.
• …
History
• First implementation on 1991
• submitted to IETF on 1998. RFC 4960 defines
  the protocol. RFC 3286 provides an introduction.
  (RFC2960 and RFC3309 are obsoleted).
• Designed for telecom signaling transfer at first,
  and used on other applications
• supported by Cisco, Linux, HP, Solaris, Alcatel-
  Lucent,…

           » refrence
Network layers

      Upper layer applications

TCP           UDP            SCTP


                IP


            Link Layer


          Physical Layer
Features
•   Message-based
•   Multi-homing
•   Multi-stream
•   Reliable transfer
•   Robust and safety ( four way
    handshake ,heartbeat, three way
    shutdown )
Multi-homing

                 SW                           HUB
                  1                            1
      10.0.0.1
                      Alternate Path                10.0.0.3
End-point
   A                                                            End-point
                                                                   Z
     10.0.0.65
                                                    10.0.0.68
                 SW                           HUB
                  2                            2


                               Primary path
Multi-stream

                        Strm1   Strm2   Strm3
  End-point             SSN 1   SSN 1   SSN 1                     End-point
     A                                                               Z



Strm1   Strm2   Strm3
SSN 2   SSN 2   SSN 2



Strm1   Strm2   Strm3
SSN 3   SSN 3   SSN 3




                                                SSN: Stream Sequence Number
Multi-stream


  End-point                                                     End-point
     A                                                             Z
                        Strm2   Strm3
                                        Strm1   Strm2   Strm3
                        SSN 2   SSN 2
                                        SSN 1   SSN 1   SSN 1



Strm1
SSN 2



Strm1   Strm2   Strm3
SSN 3   SSN 3   SSN 3
Multi-stream


  End-point                                            End-point
     A                                                    Z
                        Strm2   Strm3
                        SSN 2   SSN 2



                                               Strm1    Strm2   Strm3
Strm1
                                               SSN 1    SSN 1   SSN 1
SSN 2



Strm1   Strm2   Strm3
SSN 3   SSN 3   SSN 3
Multi-stream


  End-point                                             End-point
     A                                                     Z
                                Strm2   Strm3
              Strm2    Strm1
                                SSN 2   SSN 2
              SSN 3    SSN 2



                                                Strm1    Strm2   Strm3
                                                SSN 1    SSN 1   SSN 1



Strm1          Strm3
SSN 3          SSN 3
Multi-stream


  End-point                                             End-point
     A                                                     Z
                                Strm2   Strm3
                                SSN 2   SSN 2



                        Strm2   Strm1
                                                Strm1    Strm2   Strm3
                        SSN 3   SSN 2
                                                SSN 1    SSN 1   SSN 1



Strm1         Strm3
SSN 3         SSN 3
Multi-stream


  End-point                                     End-point
     A                                             Z


                        Strm2   Strm1
                                        Strm1    Strm2   Strm3
                        SSN 3   SSN 2
                                        SSN 1    SSN 1   SSN 1



                                                 Strm2   Strm3
Strm1         Strm3
                                                 SSN 2   SSN 2
SSN 3         SSN 3
Multi-stream


End-point                                           End-point
   A                                                   Z
            Strm3   Strm1
            SSN 3   SSN 3



                            Strm2   Strm1
                                            Strm1    Strm2   Strm3
                            SSN 3   SSN 2
                                            SSN 1    SSN 1   SSN 1



                                                     Strm2   Strm3
                                                     SSN 2   SSN 2
Multi-stream


End-point                             End-point
   A                                     Z


              Strm2   Strm1
                              Strm1    Strm2   Strm3
              SSN 3   SSN 2
                              SSN 1    SSN 1   SSN 1



                                       Strm2   Strm3
                                       SSN 2   SSN 2


                              Strm1
                                               Strm3
                              SSN 3
                                               SSN 3
Multi-stream


End-point                              End-point
   A                                      Z



                               Strm1    Strm2   Strm3
Strm2   Strm1                  SSN 1    SSN 1   SSN 1
SSN 3   SSN 2


                                        Strm2   Strm3
                                        SSN 2   SSN 2


                               Strm1
                                                Strm3
                               SSN 3
                                                SSN 3
Multi-stream

             Strm2   Strm1
End-point    SSN 3   SSN 2           End-point
   A                                    Z



                             Strm1    Strm2   Strm3
                             SSN 1    SSN 1   SSN 1



                                      Strm2   Strm3
                                      SSN 2   SSN 2


                             Strm1
                                              Strm3
                             SSN 3
                                              SSN 3
Multi-stream


End-point                          End-point
   A                                  Z



                           Strm1    Strm2   Strm3
                           SSN 1    SSN 1   SSN 1



                           Strm1    Strm2   Strm3
                           SSN 2    SSN 2   SSN 2


                           Strm1
                                    Strm2   Strm3
                           SSN 3
                                    SSN 3   SSN 3
Status of Association
  CLOSED               COOKIE_WAIT



                                     COOKIE_ECHOED
           SHUTDOWN-
            ACK-SENT

                SHUTDOWN-
                 RECIEVED
                                 ESTABLISHED
SHUTDOWN-
   SENT


            SHUTDOWN-
             PENDING
SCTP messages
• Data -- SACK
• INIT -- INIT ACK -- COOKIE ECHO --
  COOKIE ACK
• Heartbeat -- Heartbeat ACK
• Shutdown – Shutdown ACK --
  SHUTDOWN COMPLETE
• Abort
Setting Up
      Endpoint A                                Endpoint Z
     CLOSED                                     CLOSED
                            INIT
                                                         1
   COOKIE-WAIT
                                   INIT-ACK



                         COOKIE-ECHO     *
COOKIE-ECHOED                                            2
                             *     COOKIE-ACK


ESTABLISHED                                       ESTABLISHED



              * -- User data can be attached
Transfer data
Close
                Endpoint A                            Endpoint Z

Shutdown from application

SHUTDOWN-PENDING
                            Transfer remaining data


                                SHUTDOWN
    SHUTDOWN-SENT                               SHUTDOWN-RECEIVED
                              SHUTDOWN ACK


                                                SHUTDOWN-ACK-SENT


                             SHUTDOWN COMPLETE
            CLOSED                                         CLOSED
Packet Structure




    Refer to wikipedia
Chunk structure--DATA chunk
Chunk structure--SACK chunk
Fault management
• Primary/alternate Path detection
• Resend mechanism
• Congestion control (RFC2581)
Installation on Linux (lksctp)
• Check if SCTP is installed
  – grep SCTP /proc/net/protocols
  – checksctp


• Download code from
  http://lksctp.sourceforge.net/
SCTP socket API
• One-to-many style and one-to-one style are supported.
• Please read the API standard before programming, there
  are lots of different features comparing to TCP socket.
• One-to-many server
   –   socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)
   –   bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))
   –   setsockopt(m_fds[i].fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
   –   listen(sock, 2);
   –   sctp_recvmsg(sock, buffer, BUFFER_SIZE, NULL, 0, NULL, &flags)
   –   close(sock)
• One-to-many client
   –   socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP))
   –   connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)
   –   send(sock, buffer, MSG_SIZE, 0)
   –   close(sock)
                    » Refer SCTP API
Others
• shortages
  – http://datatag.web.cern.ch/datatag/WP3/sctp/tests.


• New research
  – Concurrent multipath transfer
Reference
•   http://en.wikipedia.org/wiki/Stream_Control_Transmission_Pro
•   RFC4960
•   RFC 2581
•   http://www.youtube.com/watch?v=dIPwN-z6lVA
•   http://www.sctp.org/
•   http://www.sourceforge.net/projects/lksctp
•   http://linux.die.net/man/7/sctp
•   http://www.ibm.com/developerworks/library/l-sctp/
• http://www.linuxjournal.com/article/9784
Q&A

SCTP introduction

  • 1.
    SCTP introduction Richard Xiong 2013/2/8
  • 2.
    Motivations • Provide reliabletransfer without sequence maintenance. • The stream-oriented nature of TCP is often an inconvenience. SCTP provides message based transfer. • TCP is relatively vulnerable to denial-of- service attacks, such as SYN attacks. • …
  • 3.
    History • First implementationon 1991 • submitted to IETF on 1998. RFC 4960 defines the protocol. RFC 3286 provides an introduction. (RFC2960 and RFC3309 are obsoleted). • Designed for telecom signaling transfer at first, and used on other applications • supported by Cisco, Linux, HP, Solaris, Alcatel- Lucent,… » refrence
  • 4.
    Network layers Upper layer applications TCP UDP SCTP IP Link Layer Physical Layer
  • 5.
    Features • Message-based • Multi-homing • Multi-stream • Reliable transfer • Robust and safety ( four way handshake ,heartbeat, three way shutdown )
  • 6.
    Multi-homing SW HUB 1 1 10.0.0.1 Alternate Path 10.0.0.3 End-point A End-point Z 10.0.0.65 10.0.0.68 SW HUB 2 2 Primary path
  • 7.
    Multi-stream Strm1 Strm2 Strm3 End-point SSN 1 SSN 1 SSN 1 End-point A Z Strm1 Strm2 Strm3 SSN 2 SSN 2 SSN 2 Strm1 Strm2 Strm3 SSN 3 SSN 3 SSN 3 SSN: Stream Sequence Number
  • 8.
    Multi-stream End-point End-point A Z Strm2 Strm3 Strm1 Strm2 Strm3 SSN 2 SSN 2 SSN 1 SSN 1 SSN 1 Strm1 SSN 2 Strm1 Strm2 Strm3 SSN 3 SSN 3 SSN 3
  • 9.
    Multi-stream End-point End-point A Z Strm2 Strm3 SSN 2 SSN 2 Strm1 Strm2 Strm3 Strm1 SSN 1 SSN 1 SSN 1 SSN 2 Strm1 Strm2 Strm3 SSN 3 SSN 3 SSN 3
  • 10.
    Multi-stream End-point End-point A Z Strm2 Strm3 Strm2 Strm1 SSN 2 SSN 2 SSN 3 SSN 2 Strm1 Strm2 Strm3 SSN 1 SSN 1 SSN 1 Strm1 Strm3 SSN 3 SSN 3
  • 11.
    Multi-stream End-point End-point A Z Strm2 Strm3 SSN 2 SSN 2 Strm2 Strm1 Strm1 Strm2 Strm3 SSN 3 SSN 2 SSN 1 SSN 1 SSN 1 Strm1 Strm3 SSN 3 SSN 3
  • 12.
    Multi-stream End-point End-point A Z Strm2 Strm1 Strm1 Strm2 Strm3 SSN 3 SSN 2 SSN 1 SSN 1 SSN 1 Strm2 Strm3 Strm1 Strm3 SSN 2 SSN 2 SSN 3 SSN 3
  • 13.
    Multi-stream End-point End-point A Z Strm3 Strm1 SSN 3 SSN 3 Strm2 Strm1 Strm1 Strm2 Strm3 SSN 3 SSN 2 SSN 1 SSN 1 SSN 1 Strm2 Strm3 SSN 2 SSN 2
  • 14.
    Multi-stream End-point End-point A Z Strm2 Strm1 Strm1 Strm2 Strm3 SSN 3 SSN 2 SSN 1 SSN 1 SSN 1 Strm2 Strm3 SSN 2 SSN 2 Strm1 Strm3 SSN 3 SSN 3
  • 15.
    Multi-stream End-point End-point A Z Strm1 Strm2 Strm3 Strm2 Strm1 SSN 1 SSN 1 SSN 1 SSN 3 SSN 2 Strm2 Strm3 SSN 2 SSN 2 Strm1 Strm3 SSN 3 SSN 3
  • 16.
    Multi-stream Strm2 Strm1 End-point SSN 3 SSN 2 End-point A Z Strm1 Strm2 Strm3 SSN 1 SSN 1 SSN 1 Strm2 Strm3 SSN 2 SSN 2 Strm1 Strm3 SSN 3 SSN 3
  • 17.
    Multi-stream End-point End-point A Z Strm1 Strm2 Strm3 SSN 1 SSN 1 SSN 1 Strm1 Strm2 Strm3 SSN 2 SSN 2 SSN 2 Strm1 Strm2 Strm3 SSN 3 SSN 3 SSN 3
  • 18.
    Status of Association CLOSED COOKIE_WAIT COOKIE_ECHOED SHUTDOWN- ACK-SENT SHUTDOWN- RECIEVED ESTABLISHED SHUTDOWN- SENT SHUTDOWN- PENDING
  • 19.
    SCTP messages • Data-- SACK • INIT -- INIT ACK -- COOKIE ECHO -- COOKIE ACK • Heartbeat -- Heartbeat ACK • Shutdown – Shutdown ACK -- SHUTDOWN COMPLETE • Abort
  • 20.
    Setting Up Endpoint A Endpoint Z CLOSED CLOSED INIT 1 COOKIE-WAIT INIT-ACK COOKIE-ECHO * COOKIE-ECHOED 2 * COOKIE-ACK ESTABLISHED ESTABLISHED * -- User data can be attached
  • 21.
  • 22.
    Close Endpoint A Endpoint Z Shutdown from application SHUTDOWN-PENDING Transfer remaining data SHUTDOWN SHUTDOWN-SENT SHUTDOWN-RECEIVED SHUTDOWN ACK SHUTDOWN-ACK-SENT SHUTDOWN COMPLETE CLOSED CLOSED
  • 23.
    Packet Structure Refer to wikipedia
  • 24.
  • 25.
  • 26.
    Fault management • Primary/alternatePath detection • Resend mechanism • Congestion control (RFC2581)
  • 27.
    Installation on Linux(lksctp) • Check if SCTP is installed – grep SCTP /proc/net/protocols – checksctp • Download code from http://lksctp.sourceforge.net/
  • 28.
    SCTP socket API •One-to-many style and one-to-one style are supported. • Please read the API standard before programming, there are lots of different features comparing to TCP socket. • One-to-many server – socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP) – bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr)) – setsockopt(m_fds[i].fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); – listen(sock, 2); – sctp_recvmsg(sock, buffer, BUFFER_SIZE, NULL, 0, NULL, &flags) – close(sock) • One-to-many client – socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) – connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr) – send(sock, buffer, MSG_SIZE, 0) – close(sock) » Refer SCTP API
  • 29.
    Others • shortages – http://datatag.web.cern.ch/datatag/WP3/sctp/tests. • New research – Concurrent multipath transfer
  • 30.
    Reference • http://en.wikipedia.org/wiki/Stream_Control_Transmission_Pro • RFC4960 • RFC 2581 • http://www.youtube.com/watch?v=dIPwN-z6lVA • http://www.sctp.org/ • http://www.sourceforge.net/projects/lksctp • http://linux.die.net/man/7/sctp • http://www.ibm.com/developerworks/library/l-sctp/ • http://www.linuxjournal.com/article/9784
  • 31.

Editor's Notes

  • #21 1: generate cookie by MAC, timestamp and lifespan and … Don’t create TCB to avoid DOS 2: compare the cookie received with the cookie send on INIT-ACK