SCTP introduction

31
SCTP introduction Richard Xiong 2013/2/8

description

It is a introduction of SCTP for software developer.

Transcript of SCTP introduction

Page 1: SCTP introduction

SCTP introduction

Richard Xiong2013/2/8

Page 2: SCTP introduction

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.

• …

Page 3: SCTP introduction

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

Page 4: SCTP introduction

Network layers

Upper layer applications

TCP UDP SCTP

IP

Link Layer

Physical Layer

Page 5: SCTP introduction

Features

• Message-based• Multi-homing• Multi-stream• Reliable transfer• Robust and safety ( four way

handshake ,heartbeat, three way shutdown )

Page 6: SCTP introduction

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

Page 7: SCTP introduction

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

Page 8: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm1SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Page 9: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1Strm1

SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Page 10: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm1SSN 2

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm2SSN 3

Strm1SSN 3

Page 11: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 12: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2Strm3

SSN 3Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 13: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 14: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 15: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 16: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 17: SCTP introduction

Multi-stream

End-pointA

End-pointZ

Strm1SSN 1

Strm2SSN 1

Strm3SSN 1

Strm2SSN 2

Strm3SSN 2

Strm3SSN 3

Strm1SSN 3

Strm1SSN 2

Strm2SSN 3

Page 18: SCTP introduction

Status of AssociationCLOSED COOKIE_WAIT

COOKIE_ECHOED

ESTABLISHED

SHUTDOWN-PENDING

SHUTDOWN-ACK-SENT

SHUTDOWN-SENT

SHUTDOWN-RECIEVED

Page 19: SCTP introduction

SCTP messages

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

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

WN COMPLETE• Abort

Page 20: SCTP introduction

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

Page 21: SCTP introduction

Transfer data

Page 22: SCTP introduction

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

Page 23: SCTP introduction

Packet Structure

Refer to wikipedia

Page 24: SCTP introduction

Chunk structure--DATA chunk

Page 25: SCTP introduction

Chunk structure--SACK chunk

Page 26: SCTP introduction

Fault management

• Primary/alternate Path detection• Resend mechanism• Congestion control (RFC2581)

Page 27: SCTP introduction

Installation on Linux (lksctp)

• Check if SCTP is installed– grep SCTP /proc/net/protocols – checksctp

• Download code from http://lksctp.sourceforge.net/

Page 28: SCTP introduction

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

Page 29: SCTP introduction

Others

• shortages– http://datatag.web.cern.ch/datatag/WP3/sctp/t

ests.htm

• New research– Concurrent multipath transfer

Page 30: SCTP introduction

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

Page 31: SCTP introduction

Q&A