Skip to content
/ atp-go Public
forked from stalder-n/lrp2p-go

0-RTT network protocol optimized for P2P transfers.

License

Notifications You must be signed in to change notification settings

notedit/atp-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ATP - ARQ Transmission Protocol

go test

Introduction

ATP is a 0-RTT network protocol with reliability features and built-in asymmetric encryption. It is intended to be similar in features to TCP, while avoiding some of its drawbacks.

While ATP is a general purpose protocol, it is especially useful for developers dealing with peer-to-peer transfer problems, due to its inherent capability of sending and receiving simultaneously.

Features

  • Reliable data delivery
  • Built-in asymmetric encryption
  • Connectionless communication using UDP
  • Native Go interface (ReadWriteCloser)

Simple Example

Peer 1

package main

import (
    "github.com/nicosta1132/atp"
)

func main() {
    socket := atp.SocketListen("", 3030)
    conn := socket.ConnectTo("<Peer 2 ip address>", 3030)
    _, err := conn.Write([]byte("Hello World"))
    if err != nil {
        panic(err)
    }
}

Peer 2

package main

import (
    "fmt"
    "github.com/nicosta1132/atp"
)

func main() {
    socket := atp.SocketListen("", 3030)
    conn := socket.Accept()
    readBuffer := make([]byte, 32)
    n, err := conn.Read(readBuffer)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(readBuffer[:n]))
}

Multiplexing example

Peer 1

package main

import (
    "fmt"
    "github.com/nicosta1132/atp"
)

func main() {
    socket := atp.SocketListen("", 3030)
    conn1 := socket.Accept()
    conn2 := socket.Accept()
    
    // read from first connection
    readBuffer := make([]byte, 64)
    n,err := conn1.Read(readBuffer)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(readBuffer[:n]))
    
    // read from first connection
    n,err = conn2.Read(readBuffer)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(readBuffer[:n]))
}

Peer 2

package main

import (
    "github.com/nicosta1132/atp"
)

func main() {
    socket := atp.SocketListen("", 3030)
    conn := socket.ConnectTo("<Peer 1 ip address>", 3030)
    _, err := conn.Write([]byte("Hello from Peer 2"))
    if err != nil {
        panic(err)
    }
}

Peer 3

package main

import (
    "github.com/nicosta1132/atp"
)

func main() {
    socket := atp.SocketListen("", 3030)
    conn := socket.ConnectTo("<Peer 1 ip address>", 3030)
    _, err := conn.Write([]byte("Hello from Peer 3"))
    if err != nil {
        panic(err)
    }
}

Specification

Data Segment Header

Data Offset (1B) Flags (1B) Sequence Number (4B)
Data Offset:
    Byte designating the start of payload data

Flags:
    Single byte for flag bits

Sequence Number:
    32-bit sequence number designating a segments order

ACK Segment

Data Offset (1B) Flags (1B) Sequence Number (4B) Window Size (3B)
Data Offset:
    Byte designating the start of payload data

Flags:
    Single byte for flag bits

Sequence Number:
    32-bit sequence number designating a segments order. For ACKS, this is always the last in-order number

Window Size:
    24-bit number telling the sender how large its congestion window may grow

Window Size of the SND and RCV buffer

The buffer size needs to be at least as large as the BDP. TCP can increase the window size of to 1'073'725'440 and is measured in bytes. ATP measures in packets, and a packet size of 1400 is assumed.

To allow a 100Gibt/s over a sattelite link with 600ms RTT one has:

100'000'000'000 x 0.6 / 8 = 7.5 GByte

which means that 7.5GB can be in transit. The number of packets is ~5.3mio assuming packet size of 1400. Thus, 23bit would fit, and therefore we chose 24bit, 3 bytes to store the window size.

About

0-RTT network protocol optimized for P2P transfers.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.5%
  • Makefile 0.5%