Skip to content

Transports

Erich Kästner edited this page Mar 9, 2019 · 3 revisions

Transports

Overview

A Transport represents a bidirectional line of communication between two Skywire Nodes (or Transport Edges). Skywire can use different implementations of a transport for different purposes. Currently the messaging transport is used for the coordination of the network and is the default transport in the network. Other transport types will be implemented in order to achieve different goals such as low latency, high throughput or indetectability. Skywire is designed to be able to use custom transport implementations to be able to react quickly to changing networking policies worldwide.

Each Transport is represented as a unique 16 byte (128 bit) UUID value called the Transport ID and has a Transport Type that identifies a specific implementation of the Transport.

A Transport has the following information associated with it;

  • Transport ID: A uuid.UUID value that uniquely identifies the Transport.
  • Edges: The public keys of the Transport's edge nodes (should only have 2 edges and the initiating edge should come first).
  • Type: A string value that specifies the particular implementation of the Transport.
  • Public: A bool that specifies whether the Transport is to be registered in the Transport Discovery or not. Only public transports are used for routes in the Skywire network.
  • Registered: A int64 value that is the epoch time of when the Transport is registered in Transport Discovery. A value of 0 represents the state where the Transport is not (or not yet) registered in the Transport Discovery.

Transport Module

In code, Transport is an interface, and can have many implementations.

The interface used to generate Transports of a certain Transport Type is named Transport Factory (represented by a transport.Factory interface in code).

The representation of a Transport in Transport Discovery is of the type transport.Entry.

A transport.Status type contains the status of a given Transport. Each Transport Edge provides such status, and the Transport Discovery compares the two statuses to derive the final status.

package transport

// Transport represents communication between two nodes via a single hop.
type Transport interface {

    // Read implements io.Reader
    Read(p []byte) (n int, err error)

    // Write implements io.Writer
    Write(p []byte) (n int, err error)

    // Close implements io.Closer
    Close() error

    // Local returns the local transport edge's public key.
    Local() cipher.PubKey

    // Remote returns the remote transport edge's public key.
    Remote() cipher.PubKey

    // Type returns the string representation of the transport type.
    Type() string

    // SetDeadline functions the same as that from net.Conn
    // With a Transport, we don't have a distinction between write and read timeouts.
    SetDeadline(t time.Time) error
}

// Factory generates Transports of a certain type.
type Factory interface {

    // Accept accepts a remotely-initiated Transport.
    Accept(ctx context.Context) (Transport, error)

    // Dial initiates a Transport with a remote node.
    Dial(ctx context.Context, remote cipher.PubKey) (Transport, error)

    // Close implements io.Closer
    Close() error

    // Local returns the local public key.
    Local() cipher.PubKey

    // Type returns the Transport type.
    Type() string
}
Clone this wiki locally