SCTP introduction

Post on 18-Nov-2014

722 views 2 download

description

It is a introduction of SCTP for software developer.

Transcript of SCTP introduction

SCTP introduction

Richard Xiong2013/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 t

he 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

End-pointA

SW1

SW2

HUB1

HUB2

End-pointZ

10.0.0.1

10.0.0.65

10.0.0.3

10.0.0.68

Primary path

Alternate Path

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm1SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

SSN: Stream Sequence Number

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm1SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1Strm1

SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm1SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2Strm3

SSN 3Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Status of AssociationCLOSED COOKIE_WAIT

COOKIE_ECHOED

ESTABLISHED

SHUTDOWN-PENDING

SHUTDOWN-ACK-SENT

SHUTDOWN-SENT

SHUTDOWN-RECIEVED

SCTP messages

• Data -- SACK• INIT -- INIT ACK -- COOKIE ECHO -- C

OOKIE ACK• Heartbeat -- Heartbeat ACK• Shutdown – Shutdown ACK -- SHUTDO

WN COMPLETE• Abort

Setting Up Endpoint A Endpoint Z

INIT

INIT-ACK

COOKIE-ECHO

COOKIE-ACK

*

*

* -- User data can be attached

COOKIE-WAIT

COOKIE-ECHOED

CLOSED CLOSED

ESTABLISHED ESTABLISHED

1

2

Transfer data

Close

Shutdown from application

Endpoint A Endpoint Z

SHUTDOWN SHUTDOWN-SENT

SHUTDOWN-PENDING

Transfer remaining data

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/t

ests.htm

• New research– Concurrent multipath transfer

Reference• http://en.wikipedia.org/wiki/Stream_Control_Transmissio

n_Protocol• 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