NETRAVE/NPEP.spec.md
2023-07-30 18:22:02 -06:00

32 lines
2.3 KiB
Markdown

# Netrave Packet Exchange Protocol (NPEP)
## Overview
NPEP is a custom protocol designed for the NETRAVE project to facilitate communication between the Orchestrator and the Packet Processor Consumers. It is designed to be lightweight, efficient, and secure.
## Message Types
NPEP supports the following message types:
1. `REQUEST`: Used by a consumer to request a new pcap chunk from the Orchestrator or to request permission to output a processed pcap chunk. The format is `REQUEST {CONSUMER_ID} {REQUEST_TYPE} {PCAP_CHUNK_ID}` where `{REQUEST_TYPE}` can be either `NEW` for a new pcap chunk or `OUTPUT` for output permission.
2. `UPSTATE`: Used by a consumer to update its state in the Orchestrator. The format is `UPSTATE {CONSUMER_ID} {STATE} {PCAP_CHUNK_ID}` where `{STATE}` is the current state of the consumer. The states can be `RECEIVED`, `PROCESSING`, `STASIS`, or `AT_REST`.
3. `FINISHED`: Used by a consumer to inform the Orchestrator that it has finished processing a pcap chunk. The format is `FINISHED {CONSUMER_ID} {PCAP_CHUNK_ID}`.
4. `CHANGE`: Used by the Orchestrator to request a consumer to change its state. The format is `CHANGE {CONSUMER_ID} {STATE} {URGENCY}` where `{STATE}` is the state the Orchestrator wants the consumer to change to and `{URGENCY}` is the urgency level of the state change request. The urgency levels can be `PLS` (Please), `SOON`, or `NOW`.
5. `SHUTDOWN`: Used by the Orchestrator to request a consumer to shut down. The format is `SHUTDOWN {CONSUMER_ID} {URGENCY}` where `{URGENCY}` is the urgency level of the shutdown request. The urgency levels can be `PLS` (Please), `SOON`, or `NOW`.
## Security
To ensure only legitimate consumers can connect to the Orchestrator, a unique `{HASH}` is generated by the Orchestrator and used to authenticate each consumer. This `{HASH}` is included in the `REQUEST` message.
## Error Handling
If a consumer crashes or disconnects unexpectedly, the Orchestrator will detect this through a lack of heartbeat messages and reassign the pcap chunk to another consumer.
## Data Transmission
NPEP is designed to transmit pcap data in its raw binary form to minimize overhead and maximize efficiency. The Orchestrator sends pcap data to the consumers using the `SEND PCAP {PCAP_CHUNK_ID} {PCAP_DATA}` message, where `{PCAP_DATA}` is the raw pcap data.