#ifndef _PROTOCOL_H_ #define _PROTOCOL_H_ #include #define DISCOVER_TTL 5000 #define SENDERID 42 #define MESSAGE_TTL 10 #define OPCODE_DISCOVER 0 #define OPCODE_MESSAGE 1 // discover request (c.f. class node) #define DISCOVER_SIZE sizeof(uint8_t)*3 struct discover { uint8_t opcode; // opcode = 0 uint8_t wave; // id de la wave uint8_t dist; // current node's distance }; #define MESSAGE_MIN_SIZE sizeof(uint8_t)*5 #define MESSAGE_MAX_SIZE (5 + 255) * sizeof(uint8_t) struct message { uint8_t opcode; // opcode = 1 uint8_t sender; // sender id uint8_t dist; // distance of the last sender uint8_t ttl; // time to live default = 10 uint8_t size; // size of message in bytes uint8_t *data; // actual message }; #define PROTO_SIZE MESSAGE_MAX_SIZE #endif