112 | | |
113 | | /* Service Management Layer (SML) class declaration. The functions listed here |
114 | | * are required by the VTCROSS API for service-oriented VTCROSS radio |
115 | | * architectures. |
116 | | */ |
117 | | class ServiceManagementLayer : public Component |
118 | | { |
119 | | public: |
120 | | ServiceManagementLayer(); |
121 | | ~ServiceManagementLayer(); |
122 | | |
123 | | /* Overloaded constructor that creates an SML and connects it to the |
124 | | * shell with the passed hostname and port. |
125 | | */ |
126 | | ServiceManagementLayer(const char* SML_Config, const char* serverName, \ |
127 | | const char* serverPort, int16_t clientPort); |
128 | | |
129 | | /* Connect and register with the shell component at the passed hostname |
130 | | * and port. |
131 | | */ |
132 | | void ConnectToShell(const char* serverName, const char* serverPort); |
133 | | void SendComponentType(); |
134 | | void MessageHandler(int32_t ID); |
135 | | void Shutdown(); |
136 | | void Reset(); |
137 | | void RegisterComponent(); |
138 | | void DeregisterComponent(); |
139 | | |
140 | | /* Starts the SML Server and watches it for incoming messages |
141 | | */ |
142 | | void StartSMLServer(); |
143 | | |
144 | | private: |
145 | | /* Receive the radio configuration settings from the shell and pass them |
146 | | * on to another component. |
147 | | */ |
148 | | void TransferRadioConfiguration(int32_t ID); |
149 | | |
150 | | /* Receive information regarding a completed 'experience' and pass it on |
151 | | * to the appropriate cognitive engine. |
152 | | */ |
153 | | void TransferExperience(int32_t ID); |
154 | | |
155 | | /* Listen for other components registering their available services with |
156 | | * the SML. |
157 | | */ |
158 | | void ReceiveServices(int32_t ID); |
159 | | void DeregisterServices(int32_t ID); |
160 | | |
161 | | /* Change the active mission of the radio to a new one and adjust radio |
162 | | * behavoir appropriately. |
163 | | */ |
164 | | void SetActiveMission(); |
165 | | |
166 | | /* TODO |
167 | | */ |
168 | | void RegisterCognitiveEngine(int32_t ID); |
169 | | void DeregisterCognitiveEngine(int32_t ID); |
170 | | |
171 | | /* List all services provided to the radio by registered components. |
172 | | */ |
173 | | void ListServices(); |
174 | | |
175 | | /* Load/Relead the XML configuration file. |
176 | | */ |
177 | | void ReloadConfiguration(); |
178 | | void LoadConfiguration(const char *SML_Config, Mission* &mList); |
179 | | |
180 | | /* Create and initialize the DB to hold the services |
181 | | */ |
182 | | void CreateServicesDB(); |
183 | | void CreateDataDB(); |
184 | | |
185 | | /* TODO |
186 | | */ |
187 | | void PerformActiveMission(); |
188 | | void TransactData(int32_t sourceID); |
189 | | |
190 | | /* The socket file descriptor information for the shell which this SML |
191 | | * is connected to. |
192 | | */ |
193 | | int32_t shellSocketFD; |
194 | | |
195 | | /* TODO |
196 | | */ |
197 | | int16_t CEPort; |
198 | | int16_t SMLport; |
199 | | |
200 | | uint32_t numberOfCognitiveEngines; |
201 | | |
202 | | int32_t cogEngSrv; |
203 | | int32_t activeMission; |
204 | | |
205 | | uint32_t Current_ID; |
206 | | |
207 | | bool CE_Present; |
208 | | CE_Reg *CE_List; |
209 | | Mission *miss; |
210 | | }; |
211 | | |
212 | | |
213 | | /* Policy Engine class declaration. All public functions are inherited from |
214 | | * parent classes. |
215 | | */ |
216 | | class PolicyEngine : public Engine |
217 | | { |
218 | | public: |
219 | | PolicyEngine(); |
220 | | ~PolicyEngine(); |
221 | | |
222 | | /* Overloaded constructor that creates a policy engine object and |
223 | | * connects it to either the shell or an SML, depening on the SML bool. |
224 | | */ |
225 | | PolicyEngine(const char* serverName, const char* serverPort, \ |
226 | | const bool SML); |
227 | | |
228 | | void SendComponentType(); |
229 | | void ConnectToRemoteComponent(const char* serverName, \ |
230 | | const char* serverPort, const bool SML); |
231 | | void WaitForSignal(); |
232 | | void Shutdown(); |
233 | | void Reset(); |
234 | | void RegisterComponent(); |
235 | | void DeregisterComponent(); |
236 | | |
237 | | void RegisterServices(); |
238 | | void DeregisterServices(); |
239 | | |
240 | | private: |
241 | | /* Parse and load/reload policies into the policy engine. |
242 | | */ |
243 | | void LoadPolicies(); |
244 | | void ReloadPolicies(); |
245 | | |
246 | | /* Return a decision made by the policy engine regarding a certain set |
247 | | * of transmission parameters. |
248 | | */ |
249 | | void SendPEDecision(struct Parameter pList[], struct Radio_Info *radio_info, \ |
250 | | int32_t decision_array[]); |
251 | | |
252 | | /* Validate a set of transmission parameters received from the radio. |
253 | | */ |
254 | | void ValidateParameters(); |
255 | | |
256 | | /* The SML_present bool reflects whether or not the remote component |
257 | | * this object is connected to is an SML. If it isn't, then it must be |
258 | | * a shell. The socketFD stores the socket file descriptor for this |
259 | | * connection. |
260 | | */ |
261 | | bool SML_present; |
262 | | int32_t commandSocketFD; |
263 | | }; |
264 | | |
265 | | |
266 | | /* Cognitive Engine class declaration. All public functions are inherited from |
267 | | * parent classes. |
268 | | */ |
269 | | class CognitiveEngine : public Engine |
270 | | { |
271 | | public: |
272 | | CognitiveEngine(); |
273 | | ~CognitiveEngine(); |
274 | | |
275 | | /* Overloaded constructor that creates a cognitive engine object and |
276 | | * connects it to either the shell or an SML, depening on the SML bool. |
277 | | */ |
278 | | CognitiveEngine(const char* serverName, const char* serverPort, \ |
279 | | const bool SML); |
280 | | |
281 | | void SendComponentType(); |
282 | | void ConnectToRemoteComponent(const char* serverName, \ |
283 | | const char* serverPort, const bool SML); |
284 | | void WaitForSignal(); |
285 | | void Shutdown(); |
286 | | void Reset(); |
287 | | void RegisterComponent(); |
288 | | void DeregisterComponent(); |
289 | | |
290 | | void RegisterServices(); |
291 | | void DeregisterServices(); |
292 | | |
293 | | private: |
294 | | /* Receive the transmitted radio configuration from the radio itself |
295 | | * (the CE will not always be local to the radio). |
296 | | */ |
297 | | void ReceiveRadioConfiguration(); |
298 | | |
299 | | /* Receive an 'experience' report from the radio. |
300 | | */ |
301 | | void ReceiveExperience(); |
302 | | |
303 | | /* Find the most optimal set of transmission parameters given certain |
304 | | * observables and possibly a service if the SML component is present |
305 | | * and active. |
306 | | */ |
307 | | Parameter *GetSolution(Observable *observables, Parameter *currentParameters); |
308 | | Parameter *GetSolution(Observable *observables, Parameter *currentParameters, \ |
309 | | std::string service); |
310 | | |
311 | | /* Receive a feedback from the radio regarding the performance of a |
312 | | * certain set of parameters, possibly associated with a service. |
313 | | * |
314 | | * Feedback is a single set of performance statistics that is achieved |
315 | | * corresponding to a specific set of transmission parameters. Feedback |
316 | | * helps a Cognitive Engine make better future decisions based upon |
317 | | * more accurate performance statistics. |
318 | | */ |
319 | | void ReceiveFeedback(Observable *observables,\ |
320 | | Parameter *parameters); |
321 | | void ReceiveFeedback(Observable *observables, \ |
322 | | Parameter *parameters, std::string service); |
323 | | |
324 | | |
325 | | /* BuildCognitiveEngine performs the CE implementation specific work |
326 | | * that defines the internals of a CE. For example, a CBR CE engine |
327 | | * would build the case-base reasoner or create the database, a neural |
328 | | * network based CE may perform the initial training, a GA based CE |
329 | | * may build the chromosome structure. |
330 | | */ |
331 | | void BuildCognitiveEngine(); |
332 | | |
333 | | /* The SML_present bool reflects whether or not the remote component |
334 | | * this object is connected to is an SML. If it isn't, then it must be |
335 | | * a shell. The socketFD stores the socket file descriptor for this |
336 | | * connection. |
337 | | */ |
338 | | bool SML_present; |
339 | | int32_t commandSocketFD; |
340 | | |
341 | | // TODO Need a description for these fields. Are these radio utilites, |
342 | | // parameters, and observables global to the whole system? |
343 | | Utility *uList; |
344 | | Parameter *pList; |
345 | | Observable *oList; |
346 | | struct Radio_Info *radioInfo; |
347 | | }; |
348 | | |
349 | | /* Cognitive Radio Shell class declaration. |
350 | | */ |
351 | | class CognitiveRadioShell |
352 | | { |
353 | | public: |
354 | | CognitiveRadioShell(); |
355 | | ~CognitiveRadioShell(); |
356 | | |
357 | | /* Overloaded constructor that creates a CR Shell object and loads the |
358 | | * passed radio configuration XML file. |
359 | | */ |
360 | | CognitiveRadioShell(const char* radioConfig, int16_t primaryPort, \ |
361 | | int16_t policyPort, int16_t commandPort); |
362 | | |
363 | | /* Ask for the component type of a remote component via sockets, or |
364 | | * respond to such a query sent to the shell itself. |
365 | | */ |
366 | | std::string GetRemoteComponentType(int32_t socketFD); |
367 | | void SendComponentType(int32_t socketFD); |
368 | | |
369 | | void Shutdown(); |
370 | | void Reset(); |
371 | | |
372 | | /* Start all the socket servers */ |
373 | | void StartShellServer(); |
374 | | |
375 | | int32_t LoadRadioConfiguration(const char* radioConfig, Parameter* &pList, \ |
376 | | Utility* &uList, Observable* &oList, Radio_Info* radioInfo); |
377 | | private: |
378 | | /* Parse and load/reload policies into the policy engine. |
379 | | */ |
380 | | void LoadPolicies(); |
381 | | void ReloadPolicies(); |
382 | | |
383 | | /* Register and Deregister the different components. |
384 | | */ |
385 | | void RegisterCognitiveEngine(int32_t socketFD); |
386 | | void DeregisterCognitiveEngine(int32_t socketFD); |
387 | | void RegisterPolicyEngine(int32_t socketFD); |
388 | | void DeregisterPolicyEngine(int32_t socketFD); |
389 | | void RegisterSML(int32_t socketFD); |
390 | | void DeregisterSML(int32_t socketFD); |
391 | | |
392 | | void SetActiveMission(int32_t socketFD); |
393 | | |
394 | | /* Handle a message that is received from a component. |
395 | | */ |
396 | | int32_t HandleMessage(int32_t socketFD); |
397 | | |
398 | | /* Send optimization request to primary port FD. |
399 | | */ |
400 | | void GetOptimalParameters(int32_t socketFD); |
401 | | |
402 | | /* TODO |
403 | | */ |
404 | | bool SendRadioConfiguration(int32_t socketFD); |
405 | | bool SendRadioExperience(int32_t socketFD); |
406 | | |
407 | | /* TODO |
408 | | */ |
409 | | bool UpdateParameterPerformance(int32_t socketFD); |
410 | | |
411 | | /* TODO |
412 | | */ |
413 | | bool SML_present; |
414 | | bool PE_present; |
415 | | bool CE_present; |
416 | | |
417 | | /* TODO |
418 | | */ |
419 | | int32_t numberOfCognitiveEngines; |
420 | | |
421 | | /* TODO |
422 | | */ |
423 | | int16_t primaryPort; |
424 | | int16_t policyPort; |
425 | | int16_t commandPort; |
426 | | |
427 | | /* TODO |
428 | | */ |
429 | | int32_t ceSocketFD; |
430 | | int32_t commandSocketFD; |
431 | | int32_t policySocketFD; |
432 | | |
433 | | /* TODO |
434 | | */ |
435 | | Utility *utils; |
436 | | Parameter *params; |
437 | | Observable *observables; |
438 | | |
439 | | /* TODO |
440 | | */ |
441 | | struct Radio_Info *radio_info; |
442 | | }; |
443 | | |