npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nodertc/sctp

v0.1.0

Published

SCTP network protocol (RFC4960) in plain js

Downloads

11

Readme

@nodertc/sctp

stability-experimental Build Status npm node license downloads

SCTP network protocol RFC4960 in plain js

Install

npm i @nodertc/sctp

Usage

const securesocket = dtls.connect(/*...*/);

const socket = sctp.connect({
  localPort: 5000,
  port: 5000,
  transport: securesocket,
});

socket.on('connect', socket => {
  console.log('socket connected')
  socket.write(Buffer.from('010003010000001000110008000003ea', 'hex'))
})

socket.on('data', buffer => {
  console.log('socket received data from server', buffer.toString())
  socket.end()
})

In UDP mode host and localAddress will be ignored, because addressing is provided by underlying transport.

Also note that in most cases "passive" connect is a better alternative to creating server.

passive option disables active connect to remote peer. Socket waits for remote connection, allowing it only from indicated remote port. This unusual option doesn't exist in TCP API.

new net.Socket([options])

  • options [Object]

For SCTP socketss, available options are:

  • ppid [number] Payload protocol id (see below)
  • stream_id [number] SCTP stream id. Default: 0
  • unordered [boolean] Indicate unordered mode. Default: false
  • no_bundle [boolean] Disable chunk bundling. Default: false

Note: SCTP does not support a half-open state (like TCP) wherein one side may continue sending data while the other end is closed.

socket.connect(options[, connectListener])

  • options [Object]
  • connectListener [Function] Common parameter of socket.connect() methods. Will be added as a listener for the 'connect' event once.

For SCTP connections, available options are:

  • port [number] Required. Port the socket should connect to.
  • host [string] Host the socket should connect to. Default: 'localhost'
  • localAddress [string] Local address the socket should connect from.
  • localPort [number] Local port the socket should connect from.
  • MIS [number] Maximum inbound streams. Default: 2
  • OS [number] Requested outbound streams. Default: 2
  • passive [boolean] Indicates passive mode. Socket will not connect, but allow connection of remote socket from host:port. Default: false
  • transport [stream.Duplex] Any valid Duplex stream.

socket.createStream(id)

Creates SCTP stream with stream id. Those are SCTP socket sub-streams.

After the association is initialized, the valid outbound stream identifier range for either endpoint shall be 0 to min(local OS, remote MIS)-1.

You can check this negotiated value by referring to socket.OS after 'connect' event. id should be less the socket.OS.

Result is stream.Writable.

const stream = socket.createStream(1)
stream.write('some data')

Socket events

See Net module documentation.

For SCTP additional event 'stream' is defined. It signals that incoming data chunk were noticed with new SCTP stream id.

socket.on('stream', (stream, id) => {
  stream.on('data', data => {
    // Incoming data
  })
})

sctp.defaults(options)

Function sets default module parameters. Names follow net.sctp conventions. Returns current default parameters.

See sysctl -a | grep sctp

Example:

sctp.defaults({
  rto_initial: 500,
  rto_min: 300,
  rto_max: 1000,
  sack_timeout: 150,
  sack_freq: 2,
})

sctp.PPID

sctp.PPID is an object with SCTP Payload Protocol Identifiers

{
  SCTP: 0,
  IUA: 1,
  M2UA: 2,
  M3UA: 3,
  SUA: 4,
  M2PA: 5,
  V5UA: 6,
  H248: 7,
  BICC: 8,
  ...
  }

RFC to implement

License

  • MIT, 2017-2018 © Vladimir Latyshev
  • MIT, 2018 © Dmitriy Tsvettsikh