Free Electron
MPP.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __MPP_h__
8 #define __MPP_h__
9 
10 // Multi-Player Protocol (MPP)
11 // Protocol of multi-Peer racing
12 
13 namespace beacon
14 {
15 
16 // Messages from client nodes to the Beacon
17 enum NodeMessageType
18 {
19  registrationRequest = 0x40, // Registration message
20  shutdown, // Shutdown message (unregister node and inform other nodes)
21  keepAlive, // Message to tell the beacon that the node is still alive
22  timeSyncRequest, // Time sync request
23 
24  // Global calatalog messages
25  getRequest,
26  setRequest,
27  unsetRequest,
28  clearRequest,
29  getRegexRequest
30 };
31 
32 // Messages from the Beacon to the client nodes
33 enum BeaconMessageType
34 {
35  nodeList = 0x80,
36  currentTime,
37  keepAliveResponse,
38 
39  // Global calatalog messages
40  getResults,
41  setResults,
42  unsetResults,
43  clearResults,
44  getRegexResults
45 };
46 
47 #pragma pack(push,1)
48 struct MPPmessageHeader
49 {
50  uint8_t msgType;
51  uint32_t msgLen;
52 };
53 
54 #define REG_TYPE_SIZE 4
55 
56 struct RegisterNodeMsg
57 {
58  MPPmessageHeader header;
59  uint16_t responsePort; // Port to use for responses to request
60  uint32_t CRC;
61 };
62 
63 struct ShutdownSimMsg
64 {
65  MPPmessageHeader header;
66  uint32_t id;
67  uint32_t CRC;
68 };
69 
70 struct KeepAliveMsg
71 {
72  MPPmessageHeader header;
73  uint16_t responsePort;
74  uint32_t id;
75  uint32_t CRC;
76 };
77 
78 struct KeepAliveResponseMsg
79 {
80  MPPmessageHeader header;
81  uint64_t globalDictionaryUpdateCounter;
82  uint32_t CRC;
83 };
84 
85 struct TimeSyncRequestMsg
86 {
87  MPPmessageHeader header;
88  uint16_t responsePort;
89  int64_t clientTime;
90  int64_t estBeaconTime;
91  uint32_t CRC;
92 };
93 
94 struct CurrentTimeMsg
95 {
96  MPPmessageHeader header;
97  int64_t clientTime;
98  int64_t estBeaconTime;
99  int64_t BeaconTime;
100  uint32_t CRC;
101 };
102 
103 struct GDSimpleRequestMsg
104 {
105  MPPmessageHeader header;
106  uint16_t responsePort;
107  uint8_t id;
108  uint32_t CRC;
109 };
110 
111 struct GDRequestMsg
112 {
113  MPPmessageHeader header;
114  uint16_t responsePort;
115  uint8_t id;
116  char data[1]; // place holder for string data
117 };
118 
119 struct GDResponseMsg
120 {
121  MPPmessageHeader header;
122  uint16_t responsePort;
123  uint64_t updateCounter;
124  char data[1]; // place holder for string data
125 };
126 
127 struct GDSimpleResponseMsg
128 {
129  MPPmessageHeader header;
130  uint16_t result;
131  uint64_t updateCounter;
132  uint32_t CRC;
133 };
134 
135 struct Node
136 {
137  uint8_t id;
138  uint32_t ipAddress;
139 
140  Node(const uint8_t _id, const uint32_t _ipdAddress)
141  {
142  id = _id;
143  ipAddress = _ipdAddress;
144  }
145 };
146 
147 #define MAX_BEACON_NODES 200
148 
149 struct NodeListMsg
150 {
151  MPPmessageHeader header;
152  uint8_t yourID;
153  uint64_t globalDictionaryUpdateCounter;
154  uint8_t numNodes;
155  Node nodeList[MAX_BEACON_NODES];
156  uint32_t CRC;
157 };
158 
159 #pragma pack(pop)
160 
161 } // namespace beacon
162 
163 #endif // __MPP_h__
Definition: BeaconClient.cc:16