Protocol Headers
TaskHeader
-
class TaskHeader : public Header
Abstract base class for task-based protocol headers.
TaskHeader defines the minimal interface for headers used in computing scenarios. It provides:
Message type identification (request vs response)
Task identification for routing and correlation
Payload size calculation for TCP stream reassembly
Implementations MUST serialize messageType (1 byte) followed by taskId (8 bytes, network byte order) as the first 9 bytes. This common prefix enables the EdgeOrchestrator to peek the taskId for response routing without knowing the concrete header type.
Example usage:
// Create a concrete header SimpleTaskHeader concrete; concrete.SetMessageType(TaskHeader::TASK_REQUEST); concrete.SetTaskId(42); // Use via base class reference for routing const TaskHeader& base = concrete; if (base.IsRequest()) { uint64_t taskId = base.GetTaskId(); // Route request based on taskId... }
Subclassed by ns3::SimpleTaskHeader
Public Types
Public Functions
-
TaskHeader()
Default constructor.
-
~TaskHeader() override
Virtual destructor.
-
virtual MessageType GetMessageType() const = 0
Get the message type.
Returns TASK_REQUEST or TASK_RESPONSE for standard messages. Derived classes may define additional message types beyond these.
- Returns:
The message type.
-
virtual void SetMessageType(MessageType messageType) = 0
Set the message type.
- Parameters:
messageType – The message type.
-
virtual uint64_t GetTaskId() const = 0
Get the task identifier.
The task ID uniquely identifies a task for routing responses back to the originating client.
- Returns:
The unique task ID.
-
virtual void SetTaskId(uint64_t taskId) = 0
Set the task identifier.
- Parameters:
taskId – The unique task ID.
-
virtual uint64_t GetRequestPayloadSize() const = 0
Get the payload size for a request message.
Used for TCP stream reassembly. The payload size is the number of bytes following the header in a request message.
- Returns:
Payload size in bytes.
-
virtual uint64_t GetResponsePayloadSize() const = 0
Get the payload size for a response message.
Used for TCP stream reassembly. The payload size is the number of bytes following the header in a response message.
- Returns:
Payload size in bytes.
-
bool IsRequest() const
Check if this is a request message.
- Returns:
True if message type equals TASK_REQUEST.
-
bool IsResponse() const
Check if this is a response message.
- Returns:
True if message type equals TASK_RESPONSE.
Public Static Functions
-
static TypeId GetTypeId()
Get the type ID.
- Returns:
The object TypeId.
SimpleTaskHeader
-
class SimpleTaskHeader : public ns3::TaskHeader
Header for task offload packets.
This header serializes task metadata for transmission between clients and backends. It includes the task identifier, compute demand, and input/output data sizes.
Public Functions
-
virtual MessageType GetMessageType() const override
Get the message type.
Returns TASK_REQUEST or TASK_RESPONSE for standard messages. Derived classes may define additional message types beyond these.
- Returns:
The message type.
-
virtual void SetMessageType(MessageType messageType) override
Set the message type.
- Parameters:
messageType – The message type.
-
virtual uint64_t GetTaskId() const override
Get the task identifier.
The task ID uniquely identifies a task for routing responses back to the originating client.
- Returns:
The unique task ID.
-
virtual void SetTaskId(uint64_t taskId) override
Set the task identifier.
- Parameters:
taskId – The unique task ID.
-
virtual uint64_t GetRequestPayloadSize() const override
Get the payload size for a request message.
Used for TCP stream reassembly. The payload size is the number of bytes following the header in a request message.
- Returns:
Payload size in bytes.
-
virtual uint64_t GetResponsePayloadSize() const override
Get the payload size for a response message.
Used for TCP stream reassembly. The payload size is the number of bytes following the header in a response message.
- Returns:
Payload size in bytes.
-
void SetComputeDemand(double computeDemand)
Set the compute demand in FLOPS.
- Parameters:
computeDemand – The compute demand.
-
double GetComputeDemand() const
Get the compute demand in FLOPS.
- Returns:
The compute demand.
-
void SetInputSize(uint64_t inputSize)
Set the input data size in bytes.
- Parameters:
inputSize – The input size.
-
uint64_t GetInputSize() const
Get the input data size in bytes.
- Returns:
The input size.
-
void SetOutputSize(uint64_t outputSize)
Set the output data size in bytes.
- Parameters:
outputSize – The output size.
-
uint64_t GetOutputSize() const
Get the output data size in bytes.
- Returns:
The output size.
-
bool HasDeadline() const
Check if the header has a deadline set.
- Returns:
true if deadline >= 0, false otherwise.
-
int64_t GetDeadlineNs() const
Get the task deadline.
- Returns:
The deadline as nanoseconds. Returns -1 if no deadline.
-
void SetDeadlineNs(int64_t deadlineNs)
Set the task deadline.
- Parameters:
deadlineNs – The deadline in nanoseconds. Use -1 for no deadline.
-
std::string GetAcceleratorType() const
Get the required accelerator type.
- Returns:
The accelerator type string (e.g., “GPU”, “TPU”). Empty means any.
-
void SetAcceleratorType(const std::string &type)
Set the required accelerator type.
- Parameters:
type – The accelerator type (max 16 chars, will be truncated if longer).
-
std::string ToString() const
Get a string representation of the header.
- Returns:
String representation.
Public Static Functions
-
static TypeId GetTypeId()
Get the type ID.
- Returns:
The object TypeId.
Public Static Attributes
-
static constexpr uint32_t ACCEL_TYPE_SIZE = 16
Fixed size for accelerator type string.
-
static constexpr uint32_t SERIALIZED_SIZE = 57
Serialized size of the header in bytes.
The header consists of:
messageType: 1 byte
taskId: 8 bytes
computeDemand: 8 bytes
inputSize: 8 bytes
outputSize: 8 bytes
deadline: 8 bytes (int64_t nanoseconds, -1 = no deadline)
acceleratorType: 16 bytes
-
virtual MessageType GetMessageType() const override
OrchestratorHeader
-
class OrchestratorHeader : public Header
Minimal header for orchestrator admission protocol.
OrchestratorHeader implements the admission phase of the two-phase protocol. After admission is granted, normal Task serialization (TaskHeader with TASK_REQUEST/TASK_RESPONSE) is used for execution.
Wire format (18 bytes):
messageType: 1 byte
taskId: 8 bytes (from TaskHeader for request, echoed in response)
admitted: 1 byte (for ADMISSION_RESPONSE: 0=rejected, 1=admitted)
payloadSize: 8 bytes (size of following data for header-agnostic parsing)
Public Types
-
enum MessageType
Protocol message types.
Values are chosen to be distinct from TaskHeader message types (0, 1) so the orchestrator can distinguish admission protocol messages from task data uploads by peeking at the first byte.
Values:
-
enumerator ADMISSION_REQUEST
Client requests admission (serialized DAG metadata follows)
-
enumerator ADMISSION_RESPONSE
Server responds to admission (admit/reject)
-
enumerator DATA_UPLOAD
Phase 2: full DAG data upload (dagId in taskId field)
-
enumerator ADMISSION_REQUEST
Public Functions
-
MessageType GetMessageType() const
Get the message type.
- Returns:
The message type.
-
void SetMessageType(MessageType type)
Set the message type.
- Parameters:
type – The message type.
-
uint64_t GetTaskId() const
Get the task ID.
For ADMISSION_REQUEST: matches the taskId in the following TaskHeader. For ADMISSION_RESPONSE: echoed back to correlate with the request.
- Returns:
The task ID.
-
void SetTaskId(uint64_t id)
Set the task ID.
- Parameters:
id – The task ID.
-
bool IsAdmitted() const
Check if task was admitted (for ADMISSION_RESPONSE).
- Returns:
true if admitted, false if rejected.
-
void SetAdmitted(bool admitted)
Set admission status (for ADMISSION_RESPONSE).
- Parameters:
admitted – true if task should be admitted.
-
uint64_t GetPayloadSize() const
Get the payload size.
For ADMISSION_REQUEST: Size of following TaskHeader bytes. For ADMISSION_RESPONSE: 0 (no payload).
This enables header-agnostic parsing - the orchestrator reads exactly this many bytes and passes them to the deserializer.
- Returns:
Size of data following this header in bytes.
-
void SetPayloadSize(uint64_t size)
Set the payload size.
- Parameters:
size – Size of data following this header in bytes.
-
bool IsRequest() const
Check if this is a request message.
- Returns:
true if ADMISSION_REQUEST.
-
bool IsResponse() const
Check if this is a response message.
- Returns:
true if ADMISSION_RESPONSE.
-
bool IsDataUpload() const
Check if this is a data upload message.
- Returns:
true if DATA_UPLOAD.
-
std::string GetMessageTypeName() const
Get string representation of message type.
- Returns:
Message type name.
Public Static Functions
-
static TypeId GetTypeId()
Get the type ID.
- Returns:
The object TypeId.
Public Static Attributes
-
static constexpr uint32_t SERIALIZED_SIZE = 18
Serialized size of the header in bytes.
DeviceMetricsHeader
-
class DeviceMetricsHeader : public Header
Header for device metrics reports sent from backend to orchestrator.
DeviceMetricsHeader carries accelerator state (frequency, voltage, busy status, queue length, power) from a backend to the EdgeOrchestrator’s DeviceManager. It is multiplexed on the same connection as task data using message type 6.
Wire format (30 bytes):
messageType: 1 byte (uint8_t, always DEVICE_METRICS = 6)
frequency: 8 bytes (double as uint64_t via memcpy, network byte order)
voltage: 8 bytes (double as uint64_t via memcpy, network byte order)
busy: 1 byte (uint8_t, 0=idle, 1=busy)
queueLength: 4 bytes (uint32_t, network byte order)
currentPower: 8 bytes (double as uint64_t via memcpy, network byte order)
Public Static Functions
-
static TypeId GetTypeId()
Get the type ID.
- Returns:
The object TypeId.
ScalingCommandHeader
-
class ScalingCommandHeader : public Header
Header for scaling commands sent from orchestrator to backend.
ScalingCommandHeader carries DVFS commands (target frequency, target voltage) from the EdgeOrchestrator’s DeviceManager to a backend. It is multiplexed on the same connection as task data using message type 5.
Wire format (17 bytes):
messageType: 1 byte (SCALING_COMMAND = 5)
targetFrequency: 8 bytes
targetVoltage: 8 bytes
Public Static Functions
-
static TypeId GetTypeId()
Get the type ID.
- Returns:
The object TypeId.