aodv协议/packet.h

 1 /*
 2  * aodv头
 3  */
 4 struct hdr_aodv {
 5         u_int8_t        ah_type; // 包类型
 6     
 7     static int offset_; // required by PacketHeaderManager
 8     inline static int& offset() { return offset_; }
 9     inline static hdr_aodv* access(const Packet* p) {
10         return (hdr_aodv*) p->access(offset_);
11     }
12 };
13 /**
14  * 请求包
15  */
16 struct hdr_aodv_request {
17         u_int8_t        rq_type;    // 包类型
18         u_int8_t        reserved[2];
19         u_int8_t        rq_hop_count;   // 跳数
20         u_int32_t       rq_bcast_id;    //该条广播id,id由源点给定,所以“源点+广播id”能确定一个包
21 
22         nsaddr_t        rq_dst;         // 目的节点ip地址
23         u_int32_t       rq_dst_seqno;   // 目的节点序列号,反映这个包的新鲜程度,序号越大,包越新
24         nsaddr_t        rq_src;         // 源点ip地址
25         u_int32_t       rq_src_seqno;   //源点序列号
26 
27         double          rq_timestamp;   // when REQUEST sent;
28                     
29   inline int size() { 
30   int sz = 0;
31      sz = 7*sizeof(u_int32_t);
32       assert (sz >= 0);
33     return sz;
34   }
35 };
36 /**
37  * 应答包
38  */
39 struct hdr_aodv_reply {
40         u_int8_t        rp_type;        // Packet Type
41         u_int8_t        reserved[2];
42         u_int8_t        rp_hop_count;           // Hop Count
43         nsaddr_t        rp_dst;                 // Destination IP Address
44         u_int32_t       rp_dst_seqno;           // Destination Sequence Number
45         nsaddr_t        rp_src;                 // Source IP Address
46         double            rp_lifetime;            // Lifetime
47 
48         double          rp_timestamp;           // when corresponding REQ sent;
49                         // used to compute route discovery latency
50                         
51   inline int size() { 
52   int sz = 0;
53     sz = 6*sizeof(u_int32_t);
54       assert (sz >= 0);
55     return sz;
56   }
57 
58 };
59 /**
60  * 返回错误包
61  */
62 struct hdr_aodv_error {
63         u_int8_t        re_type;                // Type
64         u_int8_t        reserved[2];            // Reserved
65         u_int8_t        DestCount;                 // DestCount
66         // List of Unreachable destination IP addresses and sequence numbers
67         nsaddr_t        unreachable_dst[AODV_MAX_ERRORS];   
68         u_int32_t       unreachable_dst_seqno[AODV_MAX_ERRORS];   
69 
70   inline int size() { 
71   int sz = 0;
72     sz = (DestCount*2 + 1)*sizeof(u_int32_t);
73     assert(sz);
74         return sz;
75   }
76 
77 };
78 
79 union hdr_all_aodv {
80   hdr_aodv          ah;
81   hdr_aodv_request  rreq;
82   hdr_aodv_reply    rrep;
83   hdr_aodv_error    rerr;
84   hdr_aodv_rrep_ack rrep_ack;
85 };

猜你喜欢

转载自www.cnblogs.com/lnu161403214/p/10029283.html