-
Notifications
You must be signed in to change notification settings - Fork 63
Packets
The Node Module handles data encapsulated within data units called Packets. Packets can be grouped within the following categories based on their use-case;
-
Settlement Packets are used by the Transport Manager to "settle" Transports. Settlement, allows the two nodes that are the edges of the transport to decide on the Transport ID to be used, and whether the Transport is to be public. Only after a Transport is settled, can the Router have access to the Transport.
Settlement Packets contain
json
encoded payload. -
Foundational Packets are used by a Router to communicate with a remote Setup Node and is used for setting up, establishing and destroying routes.
Foundational Packets are prefixed by 3 bytes: the packet size (2 bytes) and a Type (1 byte) that contains the foundational packet type.
-
Data Packets are Packets that are actually used to encapsulate data delivered between two Apps.
Data Packets are prefixed by 6 bytes; including the packet size (2 bytes) and the Route ID (4 bytes) which can have any value other than
0x00
or0x01
.
After a Transport is established between two nodes, the nodes needs to decide on the Transport ID that describes the Transport and whether the Transport is to be public or private (public Transports are to be registered in the Transport Discovery). This process is called the Settlement Handshake.
The Packets of this handshake contain json
encoded messages.
Settlement Handshake packets do not need a field for Packet-type are they are expected in a specific order.
-
Request to settle transport is sent by the Transport Initiator to the Transport Responder after a Transport connection is established.
JSON Body: Contains a
transport.SignedEntry
structure with the Transport Initiator's signature. -
Transport Responder should validate submitted
transport.SignedEntry
, and if entry is valid it should add sign it and perform transport registration in transport discovery. If registration was successful responder should send updatedtransport.SignedEntry
back to initiator.JSON Body: Contains a
transport.SignedEntry
structure with signatures from both the Transport Initiator and the Transport Responder. If the transport is registered in Transport Discovery, theSignedTransport.Registered
should contain the epoch time of registration.
If transport will fail at any step participants can chose to stop handshake procedures and close corresponding transport. Transport disconnect during the handshake should be handled appropriately by participants. Optional handshake timeout should also be supported.
Foundational packets are used for the communication between App Nodes and Setup Nodes.
The Setup Node is responsible for fulfilling Route initiating and destroying requests by communicating with the initiating, responding and intermediate nodes of the proposed route.
The following is the expected format of a Foundational Packet;
| Packet Len | Type | JSON Body |
| 2 bytes | 1 byte | ~ |
- Packet Len specifies the total packet length in bytes (exclusive of the Packet Len field).
- Type specifies the Foundational Packet Type.
- JSON Body is the packet body (in JSON format) that is unique depending on the packet type.
Foundational Packet Types Summary:
Type | Name |
---|---|
0x00 | AddRules |
0x01 | RemoveRules |
0x02 | CreateLoop |
0x03 | ConfirmLoop |
0x04 | CloseLoop |
0x05 | LoopClosed |
0xfe | ResponseFailure |
0xff | ResponseSuccess |
The follow is the structure of a Data Packet.
| Packet Len | Route ID | Payload |
| 2 bytes | 4 bytes | ~ |
Since messaging and loop communication are dependent on intermediate servers we provide acknowledgment mechanism between edge nodes. This is be done via wrapper io.ReadWriter
(AckReadWriter
) that augments existing communication channels with ack
packets. Write
calls on AckReadWrite
block until corresponding ack
packet is received.
ack
logic works in tcp
-like way: all pending ack
packets are sent with subsequent write on the opposite edge. If no write has happened within a certain interval then all pending ack
packets are flushed. Outstanding ack
packets are also be flushed on Close
call.
AckReadWriter
Is able to send and receive 2 types of packets: payload
(0x0
) and ack
(0x1
):
Format of a payload
packet:
| Packet Type | Packet ID | Payload |
| 0x0 | 1 byte | ~ |
Format of an ack
packet:
| Packet Type | Packet ID | SHA256 |
| 0x1 | 1 byte | 32 bytes |
AckReadWriter
Is able to prepend any amount of ack
packets to a payload
packet. Sequences without payload
packet are valid. Example packet sequence:
| 0x1 | 0x0 | hash | 0x1 | 0x1 | hash | 0x0 | 0x2 | payload |
This packet sequence will acknowledge received packets with ids 0
and 1
and will send packet with id 2
.
Upon reading ack
packets receiver should validate received hash for each packet.
- Skywire Testnet Rules
- Skywire Authentication System User Guide
- Skywire Whitelisting System User Guide
- Official Skyminer Guide
- Testnet Discovery Address Change Instructions
- Skywire Installation Guide
- Skyflash User Guide
- Networking guide for the official router
- Official Skyminer - Wiring
- Public Key Backup
- Skywire Rasberry Pi Installation Guide
- Skywire Systemd Service
- Skywire Manager Web Interface
- Online Status Verification User Guide
- Skywire SSH User Guide
- Skywire SOCKS5 Proxy User Guide
- Single Board Computer WiFi Hotspot
- HTTP Proxy Service with Skywire VPN
- Setting Up Multiple Virtual Machines with Skywire VPN
- Tunnel exit node traffic through VPN
- Connecting Skynodes to your own OpenVPN Server
- Change startup delay of node processes using an automated script
- Change DNS of the official images
- Automated restart script
- Automated poweroff script
- Automated restart of node app
- Automated reboot if the network connections drops off