📄 hdr_hgps.h
字号:
#ifndef hdr_hgps_h#define hdr_hgps_h#include <assert.h>#include <packet.h>#define ROUTE_UPDATE 1 //i.e. HELLO#define LOC_UPDATE 2#define LOC_QUERY 3#define LOC_QUERY_RESPONSE 4#define LOC_NOTIFICATION 5#define LOC_UPDATE_FP 6#define ERR 7#define DATA 8#define MAX_NEIGHBOR 60#define MAX_ADDR_LEN 20#define MAX_FP_IN_HELLO 8#define MAX_LOC_SERVERS 8typedef struct { int loc; int mask; //for the smallest grid, the mask is always 32}location;typedef struct { nsaddr_t id; location loc;}nodeloc;struct hdr_hgps{ int valid_; int type_; /* LOC_UPDATE, LOC_QUERY,...*/ /* dst ip node's location */ location dst_loc_; double dst_loc_time_; location src_loc_; double src_x_; double src_y_; double src_speed_; /* id's location is loc */ location loc_; nsaddr_t id_; double lastupdate_time_; double lastupdate_dst_time_; /* for LOC_UPDATE, the updated location area*/ location update_loc_; double timeout_inteval_; int in_correct_grid_; /* these are for neighbor updates, i know they are messy */ nsaddr_t neighbor_ids_[MAX_NEIGHBOR]; location neighbor_locs_[MAX_NEIGHBOR]; int neighbor_num_; /* the forwarding pointer information */ nsaddr_t fp_ids_[MAX_FP_IN_HELLO]; location fp_locs_[MAX_FP_IN_HELLO]; double fp_lastupdate_time_[MAX_FP_IN_HELLO]; location fp_old_loc; //all fp pointers are meant for grid fp_old_loc int fp_num_; nodeloc locservers_[MAX_LOC_SERVERS]; int next_locserver_; static int offset_; inline int& offset() {return offset_;} //this is a very ugly for prevent possible routing loops nsaddr_t prev_hop_[3]; int prev_hop_num_;#ifdef IDEAL_ROUTE nsaddr_t addrs_[MAX_ADDR_LEN]; nsaddr_t curr_addr_;#endif int query_forwards_; //for logging how many steps the query has taken int query_response_forwards_; //for logging how many steps the query has taken inline void init() { valid_ = 1; id_ = 0; loc_.loc = 0; loc_.mask = 0; type_ = 0; neighbor_num_ = 0; fp_num_ = 0; //rescue_=0; prev_hop_num_ = 0; in_correct_grid_ = 0; timeout_inteval_ = 0; lastupdate_time_ = 0; lastupdate_dst_time_ = 0; src_x_ = 0; src_y_ = 0; update_loc_.loc=0; update_loc_.mask = 0; dst_loc_time_ = 0.0; query_forwards_ = 0; query_response_forwards_ = 0; next_locserver_ = 0;#ifdef IDEAL_ROUTE curr_addr_ = 0;#endif } /* to be modified later*/ inline int size() { if (neighbor_num_) { return 2 * neighbor_num_; //the node ID should be enough for 2^16(?) }else{ return 5; //a rough estimate } }};#endif hdr_hgps_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -