xtaci / Smux
Licence: mit
A Stream Multiplexing Library for golang with least memory usage
Stars: ✭ 818
Programming Languages
go
31211 projects - #10 most used programming language
Labels
Projects that are alternatives of or similar to Smux
Nginx Rtmp Docker
Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.
Stars: ✭ 506 (-38.14%)
Mutual labels: stream
Gulp Gh Pages
A gulp 4 plugin to publish contents to Github pages
Stars: ✭ 611 (-25.31%)
Mutual labels: stream
Ustreamer
µStreamer - Lightweight and fast MJPG-HTTP streamer
Stars: ✭ 533 (-34.84%)
Mutual labels: stream
Lol Html
Low output latency streaming HTML parser/rewriter with CSS selector-based API
Stars: ✭ 566 (-30.81%)
Mutual labels: stream
Moose
🦌 An application to stream, cast and download torrents.
Stars: ✭ 656 (-19.8%)
Mutual labels: stream
Zerocode
A community-developed, free, open source, microservices API automation and load testing framework built using JUnit core runners for Http REST, SOAP, Security, Database, Kafka and much more. Zerocode Open Source enables you to create, change, orchestrate and maintain your automated test cases declaratively with absolute ease.
Stars: ✭ 482 (-41.08%)
Mutual labels: stream
Node Fetch
A light-weight module that brings the Fetch API to Node.js
Stars: ✭ 7,176 (+777.26%)
Mutual labels: stream
Endoscope
Endoscope lets you to stream live video between android devices over Wi-Fi! 📱📲
Stars: ✭ 587 (-28.24%)
Mutual labels: stream
Homebridge Camera Ffmpeg
Homebridge Plugin Providing FFmpeg-based Camera Support
Stars: ✭ 726 (-11.25%)
Mutual labels: stream
Cubit
Cubit is a lightweight state management solution. It is a subset of the bloc package that does not rely on events and instead uses methods to emit new states.
Stars: ✭ 539 (-34.11%)
Mutual labels: stream
Streamhut
Stream your terminal to web without installing anything 🌐
Stars: ✭ 676 (-17.36%)
Mutual labels: stream
Libjitsi
Advanced Java media library for secure real-time audio/video communication.
Stars: ✭ 536 (-34.47%)
Mutual labels: stream
Sonerezh
A self-hosted, web-based application to stream your music, everywhere.
Stars: ✭ 750 (-8.31%)
Mutual labels: stream
Scikit Multiflow
A machine learning package for streaming data in Python. The other ancestor of River.
Stars: ✭ 485 (-40.71%)
Mutual labels: stream
Pbjvideoplayer
▶️ video player, simple way to play and stream media on iOS/tvOS
Stars: ✭ 620 (-24.21%)
Mutual labels: stream
Nuclear
Streaming music player that finds free music for you
Stars: ✭ 7,133 (+772%)
Mutual labels: stream
Grpc By Example Java
A collection of useful/essential gRPC Java Examples
Stars: ✭ 709 (-13.33%)
Mutual labels: stream
Introduction
Smux ( Simple MUltipleXing) is a multiplexing library for Golang. It relies on an underlying connection to provide reliability and ordering, such as TCP or KCP, and provides stream-oriented multiplexing. The original intention of this library is to power the connection management for kcp-go.
Features
- Token bucket controlled receiving, which provides smoother bandwidth graph(see picture below).
- Session-wide receive buffer, shared among streams, fully controlled overall memory usage.
- Minimized header(8Bytes), maximized payload.
- Well-tested on millions of devices in kcptun.
- Builtin fair queue traffic shaping.
- Per-stream sliding window to control congestion.(protocol version 2+).
Documentation
For complete documentation, see the associated Godoc.
Benchmark
$ go test -v -run=^$ -bench .
goos: darwin
goarch: amd64
pkg: github.com/xtaci/smux
BenchmarkMSB-4 30000000 51.8 ns/op
BenchmarkAcceptClose-4 50000 36783 ns/op
BenchmarkConnSmux-4 30000 58335 ns/op 2246.88 MB/s 1208 B/op 19 allocs/op
BenchmarkConnTCP-4 50000 25579 ns/op 5124.04 MB/s 0 B/op 0 allocs/op
PASS
ok github.com/xtaci/smux 7.811s
Specification
VERSION(1B) | CMD(1B) | LENGTH(2B) | STREAMID(4B) | DATA(LENGTH)
VALUES FOR LATEST VERSION:
VERSION:
1/2
CMD:
cmdSYN(0)
cmdFIN(1)
cmdPSH(2)
cmdNOP(3)
cmdUPD(4) // only supported on version 2
STREAMID:
client use odd numbers starts from 1
server use even numbers starts from 0
cmdUPD:
| CONSUMED(4B) | WINDOW(4B) |
Usage
func client() {
// Get a TCP connection
conn, err := net.Dial(...)
if err != nil {
panic(err)
}
// Setup client side of smux
session, err := smux.Client(conn, nil)
if err != nil {
panic(err)
}
// Open a new stream
stream, err := session.OpenStream()
if err != nil {
panic(err)
}
// Stream implements io.ReadWriteCloser
stream.Write([]byte("ping"))
stream.Close()
session.Close()
}
func server() {
// Accept a TCP connection
conn, err := listener.Accept()
if err != nil {
panic(err)
}
// Setup server side of smux
session, err := smux.Server(conn, nil)
if err != nil {
panic(err)
}
// Accept a stream
stream, err := session.AcceptStream()
if err != nil {
panic(err)
}
// Listen for a message
buf := make([]byte, 4)
stream.Read(buf)
stream.Close()
session.Close()
}
Status
Stable
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].