-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgp_pkt.h
151 lines (98 loc) · 4.12 KB
/
rgp_pkt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
ROUTE GUIDANCE PROTOCOL (RGP)
Coded for Final year project by
Kannan KV - 20072319
Naveen G - 20072334
Vidhoon V - 20072366
under the guidance of Dr.Ranjani Parthasarathi
The file contains the packet structure to be used in RGP protocol
for communication between nodes
*/
#ifndef __rgp_pkt_h__
#define __rgp_pkt_h__
#include <packet.h>
/* =====================================================================
Packet Formats...
===================================================================== */
#define RGPTYPE_REQUEST 0x01
#define RGPTYPE_REPLY 0x02
#define RGPTYPE_SREQ 0x03
#define RGPTYPE_SREP 0x04
/*
* Route Guidance Protocol Header Macros
*/
#define HDR_RGP_PKT(p) ((struct hdr_rgp_pkt*)hdr_rgp_pkt::access(p))
#define HDR_RGP_REQUEST_PKT(p) ((struct hdr_rgp_request_pkt*)hdr_rgp_pkt::access(p))
#define HDR_RGP_REPLY_PKT(p) ((struct hdr_rgp_reply_pkt*)hdr_rgp_pkt::access(p))
//specific for speed guidance
#define HDR_RGP_SREQUEST_PKT(p) ((struct hdr_rgp_speedreq_pkt*)hdr_rgp_pkt::access(p))
#define HDR_RGP_SREPLY_PKT(p) ((struct hdr_rgp_speedrep_pkt*)hdr_rgp_pkt::access(p))
//header for RGP packets
struct hdr_rgp_pkt {
int pkt_type_; // type of packet inside
inline int& pkt_type() { return pkt_type_; }
static int offset_;
inline static int& offset() { return offset_; }
inline static hdr_rgp_pkt* access(const Packet* p) {
return (hdr_rgp_pkt*)p->access(offset_);
}
};
//header for RGP request packet
struct hdr_rgp_request_pkt {
int pkt_type_; // type of packet inside
nsaddr_t pkt_src_; // IP address of node which originated this packet
int current_id_; // Id of current road
int destination_id_; // Id of destination road to be reached
inline int& pkt_type() { return pkt_type_; }
inline int& current_id() { return current_id_; }
inline int& destination_id() { return destination_id_; }
inline nsaddr_t& pkt_src() { return pkt_src_; }
};
//header for RGP reply packet
struct hdr_rgp_reply_pkt {
int pkt_type_; // type of packet inside
nsaddr_t pkt_src_; // IP address of node which originated this packet
int data_road_id_; // road ID for which data is sent
double data_time_stamp_; // timestamp at which values were taken
double data_field_; // cost calculation parameter
bool exception_state_; // exception condition
inline int& pkt_type() { return pkt_type_; }
inline int& data_road_id() { return data_road_id_; }
inline double& data_time_stamp() { return data_time_stamp_; }
inline double& data_field() { return data_field_; }
inline bool& exception_state() { return exception_state_; }
inline nsaddr_t& pkt_src() { return pkt_src_; }
};
//header for RGP speed request packet
struct hdr_rgp_speedreq_pkt {
int pkt_type_; // type of packet inside
nsaddr_t pkt_src_; // IP address of node which originated this packet
int current_id_; // Id of current road
inline int& pkt_type() { return pkt_type_; }
inline int& current_id() { return current_id_; }
inline nsaddr_t& pkt_src() { return pkt_src_; }
};
//header for RGP reply packet
struct hdr_rgp_speedrep_pkt {
int pkt_type_; // type of packet inside
nsaddr_t pkt_src_; // IP address of node which originated this packet
int data_road_id_; // road ID for which data is sent
double xpos_; // x loc
double ypos_;// y loc
double speed_; // speed of vehicle
double destx;
double desty;
inline int& pkt_type() { return pkt_type_; }
inline int& data_road_id() { return data_road_id_; }
inline double& xpos() { return xpos_; }
inline double& ypos() { return ypos_; }
inline double& speed() { return speed_; }
inline nsaddr_t& pkt_src() { return pkt_src_; }
};
// for size calculation of header-space reservation
union hdr_all_rgp {
hdr_rgp_pkt dummy1;
hdr_rgp_request_pkt dummy2;
hdr_rgp_reply_pkt dummy3;
};
#endif