Code Monkey home page Code Monkey logo

suft's Introduction

Introduction

Build Status GoDoc

The SUFT (Small-scale UDP Fast Transmission) Protocol is an application layer transmission protocol based on UDP and implemented in Golang. It has lower latency than TCP and provides reliable and ordered delivery of a stream of octets under plain congestion control.

The protocol seeks for maximized throughput and minimizes impact of lost packets on throughput. It is only for small/medium-scale communication or some situations where TCP is not applicable.

Goals & Features

  • Transmitting model has predictable performance.
  • Fast retransmission mode does better on lossy link.
  • Minimum retransmission mode doesn't waste traffic.
  • No resource consumption while the connection is idle.
  • Special modes for certain situations.

Protocol APIs

SUFT implements the Golang: net.Conn and net.Listener interfaces completely.

import "github.com/spance/suft/protocol"

e, err := suft.NewEndpoint(p *suft.Params)
// for server
conn := e.Listen() // or e.Accept()
// for client
conn, err := e.Dial(rAddr string)
// your business ...
conn.Close()
e.Close()

Basic Theories

scnt(sender: the count of unique data packets) and dups(sender: retransmission counter)

Lose Rate = dups/(scnt + dups)

Retransmit Rate = dups/scnt

latency, window and traffic speed

Speed = (1000 / latency) * mss * win

License

GPL version 3 or any later version

SUFT Protocol
Copyright (C) 2016  spance, l2dy

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Tool Usage

"suft-nc" package include a tool for testing, similar to netcat (nc).

Build with go get -u -v github.com/spance/suft/suft-nc

./suft-nc [-l addr:port] [-r addr:port] [-s] [-b 10] [-fr] < [send_file] > [recv_file]

-l:  local bind address, e.g. localhost:9090 or :8080
-r:  remote address (for client), e.g. 8.8.8.8:9090 or examples.com:8080
-b:  max bandwidth of sending in mbps (be careful, see Notes#2)
-s:  for server
-fr: enable fast retransmission (useful for lossy link)
-ft: flat traffic (slow down bursty traffic, useful when sender has more bandwidth than receiver)

Examples:

// send my_file to remote in 10mbps
remote# ./suft-nc -l :9090 -s > recv_file
local# ./suft-nc -r remote:9090 -b 10 -fr < my_file
// recv my_file from remote in 50mbps
remote# ./suft-nc -l :9090 -s -b 50 -fr < my_file
local# ./suft-nc -r remote:9090 > recv_file
// simple chat room
remote# ./suft-nc -l :9090 -s
local# ./suft-nc -r remote:9090

Notes:

  1. The target to be connected shouldn't be behind NAT (or should use port mapping).
  2. Use improper bandwidth(-b) may waste huge bandwidth and may be suspected of carrying out flood attack.

How to test?

// remote, send 100MB stream in 50mbps (your bandwidth bottleneck)
remote# dd if=/dev/zero bs=1M count=100 status=none | ./suft-nc -s -l :9090 -b 50 -fr -ft
// status=none or status=noxfer

// local console#1, monitor traffic(for simplicity, we can use bmon)
local# bmon -p eth0
// local console#2, recv stream
local# ./suft-nc -r remote:9090 > /dev/null

suft's People

Contributors

spance avatar l2dy avatar l2dybot avatar gitter-badger avatar

Watchers

Hongcai Deng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.