Categorygithub.com/georgeyanev/go-sctp
modulepackage
0.12.0
Repository: https://github.com/georgeyanev/go-sctp.git
Documentation: pkg.go.dev

# README

SCTP for Go

Go Tests Go Reference codecov Fork me on GitHub

go-sctp is a Golang package that provides an efficient interface for working with the Stream Control Transmission Protocol (SCTP). SCTP support in the Go ecosystem has been sparse and go-sctp aims to fill this gap. It offers high-level abstractions like SCTPConn, SCTPListener, and SCTPAddr, seamlessly integrating with Go's net package by implementing net.Conn, net.Listener, and net.Addr. Also, it integrates with Go's runtime network poller to provide asynchronous low-level I/O and deadline support.

This library supports SCTP's one-to-one mode and is designed specifically for Linux environments. It mimics most of the TCP functionality implemented in Go's net package, with added support for multihoming, multistreaming and SCTP notifications.

go-sctp interfaces directly with the kernel SCTP module, leveraging system calls provided by Go's unix and syscall packages. This eliminates the need for external SCTP libraries, ensuring a lightweight, efficient, and dependency-free implementation.

Well-structured and comprehensive documentation is prioritized as part of the development process.


Features

  • Support for one-to-one SCTP mode (SOCK_STREAM socket type)
  • Use of non-blocking sockets
  • Integration with go's runtime network poller through os.File
  • Dial, Listen, Accept functionality following Go's TCP implementation logic
  • Basic SCTP read and write through SCTPConn.Read and SCTPConn.Write
  • Enhanced SCTP read and write through SCTPConn.ReadMsg and SCTPConn.WriteMsg
  • Deadline support for read/write/accept operations
  • Multi-streaming support through sctp.SndInfo and sctp.RcvInfo structures
  • Multi-homing support embedded in SCTPAddr
  • SCTP Notifications support
  • Exported socket options (i.e. SCTP_ADAPTATION_LAYER, SCTP_DISABLE_FRAGMENTS)
  • Runtime re-binding support through BindAdd and BindRemove
  • Shutdown and Abort support
  • Most of the TCP tests in Go's net package applied here to SCTP
  • Well documented

For a complete list of features and the history of changes introduced in each version, refer to the CHANGELOG.md.


Getting

go get -u github.com/georgeyanev/go-sctp


Usage

Most functionality mirrors Go's TCP implementation, making it intuitive to use. For example:

Dial:

conn, err := sctp.Dial("sctp4", "127.0.0.1/127.0.0.2:3868")

Listen:

ln, err := sctp.Listen("sctp4", "127.0.0.1/127.0.0.2:3868")

Accept:

conn, err := ln.Accept()

Kernel parameters:

For optimal performance set the kernel parameters net.core.rmem_max and net.core.wmem_max to at least 512KB


Contributing

Contributions are welcome! If you find a bug, have a feature request, or want to contribute code, feel free to open an issue or pull request.

# Packages

No description provided by the author

# Functions

Dial connects to the address on the named network.
DialSCTP acts like [Dial] taking SCTP addresses and returning a SCTPConn.
Htonui16 does host to network byte order for an uint16.
Htonui32 does host to network byte order for an uint32.
Listen announces on the local network address.
ListenSCTP acts like [Listen] for SCTP networks.
Ntohui16 does network to host byte order for an uint16.
Ntohui32 does network to host byte order for an uint32.
ParseEvent parses an SCTP event from a byte slice.
ResolveSCTPAddr returns an address of an SCTP end point.

# Constants

SCTP_ABORT causes the specified association to abort by sending an ABORT message to the peer.
SCTP_ACTIVE state is entered the first time after path verification.
event types.
SCTP_ADDR_ADDED shows that the address is now part of the association.
SCTP_ADDR_AVAILABLE shows that this address is now reachable.
SCTP_PEER_ADDR_CHANGE state.
SCTP_ADDR_MADE_PRIM shows that this address has now been made the primary destination address.
SCTP_ADDR_OVER is filled automatically by WriteMsg function, when a 'to' address is specified.
SCTP_PEER_ADDR_CHANGE state.
SCTP_ADDR_REMOVED shows that the address is no longer part of the association.
SCTP_ADDR_UNREACHABLE shows that the address specified can no longer be reached.
event types.
event types.
event types.
SCTP_CANT_STR_ASSOC shows that the association setup failed.
Status state values.
SCTP_COMM_LOST shows that the association has failed.
SCTP_COMM_UP shows that a new association is now ready, and data may be exchanged with this peer.
Status state values.
Status state values.
unix.MSG_CTRUNC.
SfeSndInfo flags.
SfeSndInfo flags.
SCTP_DATA_SENT indicates that the data was put on the wire.
SCTP_DATA_UNSENT indicates that the data was never put on the wire.
Status state values.
unix.MSG_FIN.
unix.MSG_EOR.
Status state values.
SCTP_INACTIVE state is entered whenever a path failure is detected.
SCTP_NOTIFICATION indicates that the received message is an SCTP event and not a data message.
no parsing due to discrepancies between sctp.h and RFC6458.
event types.
event types.
SCTP_RESTART shows that the peer has restarted.
event types.
SCTP_SENDALL has no effect for the one-to-one style socket.
event types.
Status state values.
SCTP_SHUTDOWN_COMP means the association has gracefully closed.
event types.
Status state values.
Status state values.
Status state values.
event types.
event types.
SCTP_UNCONFIRMED is the initial state of a peer address.
SCTP_UNORDERED flag requests the unordered delivery of the message.

# Variables

No description provided by the author

# Structs

AdaptationEvent is delivered by SCTP to inform the application about the peer's adaptation layer indication (When a peer sends an Adaptation Layer Indication parameter as described in RFC5061).
AssocChangeEvent informs the application that an SCTP association has either started or ended.
A Dialer contains options for connecting to an address.
InitOptions structure provides information for initializing new SCTP associations.
ListenConfig contains options for listening to an address.
PeerAddrChangeEvent is sent When a destination address of a multi-homed peer encounters a state change.
PeerAddrInfo contains information about a specific peer address of an association, including its reachability state, congestion window, and retransmission timer values.
RcvInfo structure describes SCTP receive information about a received message RcvInfo is returned by SCTPConn.ReadMsg function.
No description provided by the author
SCTPAddr represents the address of an SCTP endpoint.
No description provided by the author
No description provided by the author
SenderDryEvent is received to inform the application that the stack has no more user data to send or retransmit.
No description provided by the author
ShutdownEvent is received to inform the application that it should cease sending data.
SndInfo structure specifies SCTP options for sending SCTP messages Used in SCTPConn.WriteMsg functions.
Status structure holds current status information about an association, including association state, peer receiver window size, number of unacknowledged DATA chunks, and number of DATA chunks pending receipt.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author