?? vanetrbc_header.h
字號:
/* ------------------------------------------------------------------- * Vehicular Ad Hoc Networks: Regular Broadcasting of messages. * Skeleton for VANET-protocols. This should be considered as an * example to create other VANET protocols! * Apart from channel load, the "protocol" as it is now does not do * anything useful. * * Dan Jungels (daniel.jungels@epfl.ch) * LCA - EPFL * * * Packet Headers for the protocol * Originally written for ns2.29 * * 2005-12-15: release of first version (dj) * 2005-12-23: update and cleanup, public release (dj) * 2006-01-05: bugfix in the packet header (dj) * ------------------------------------------------------------------- */#ifndef vanetrbc_header_h#define vanetrbc_header_h// Message types#define VANETTYPE_REGBC 1// define your own message types here// Header Macros#define HDR_VANET(p) ((struct hdr_vanet*)hdr_vanet::access(p))#define HDR_VANET_RBC(p) ((struct hdr_vanet_rbc*)hdr_vanet::access(p))// define the header macros for your own message types here// general VANET header, shared by all types.// this is an easy method to access the msgtype-variable (since you don't// know which specific packet-header you have received, before having read// this variable), thus preventing you from making "unknown" castsstruct hdr_vanet { u_int8_t vn_msgtype; // type of the message (don't change!) // Header access methods (don't change!) static int offset_; // required by PacketHeaderManager inline static int& offset() { return offset_; } inline static hdr_vanet* access(const Packet* p) { return (hdr_vanet*) p->access(offset_); } // end of Header access methods. };struct hdr_vanet_rbc { // TYPE: Regular broadcast u_int8_t rbc_msgtype; // type of the message (don't change!). // It is mandatory to copy *first* all the // variables that you use in the general header // (above) to every specific header with the same // type (i.e. u_int8_t), so that you don't // overwrite the memory location when writing // data to the specific headers! (the name may be // different, a good convention is to always use // a specific prefix per specific header) // here you may add or remove fields as you wish, for the specific packet // header double rbc_timestamp; // timestamp at which the message was sent // (you may change or remove this) u_int32_t rbc_senderID; // the sender's ID // (you may change or remove this) char rbc_message[150]; // to store some data in it... (not really used // for the moment. but maybe later. you may // also include some cryptographic stuff, etc). double rbc_posx; // sender's position double rbc_posy; // calculate the size of the header (don't remove, but update) inline int size() { // The same comment as above applies. int sz = sizeof(u_int8_t) // 1 on x86 + sizeof(double) // 8 on x86 + sizeof(u_int32_t) // 4 on x86 + 150*sizeof(char) // ...*1 on x86 + sizeof(double) // 8 on x86 + sizeof(double); // 8 on x86 return sz; }};// ! add your packet types here// for size calculation of header-space reservation (don't remove!)union hdr_all_vanet { hdr_vanet vh; hdr_vanet_rbc rbc; // also add you packet types here, if you have added some above};#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -