Newer
Older
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @desc Module containing functions for GeoNetworking
*
*/
module LibItsGeoNetworking_Functions {
// Libcommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_VerdictControl {type FncRetCode;}
// LibIts
import from LibIts_TestSystem all;
import from LibIts_Interface all;
/**
* @desc Create Facility component and connects GeoNetworking port
* @param p_ptcDenm returned Facility component variable
*/
function f_ptcGeoNetworkingUp(out ItsNt p_ptcGeoNetworking) {
p_ptcGeoNetworking := ItsNt.create("GeoNetworking Tester");
// map ports
map(p_ptcGeoNetworking:geoNetworkingPort, system:geoNetworkingPort);
/**
* @desc Wait for component to finish and unmap GeoNetworking ports
function f_ptcGeoNetworkingDown(in ItsNt p_ptcGeoNetworking) runs on ItsMtc {
tc_guard.start;
alt {
[] p_ptcGeoNetworking.done {
tc_guard.stop;
}
[] tc_guard.timeout {
log("*** f_ptcGeoNetworkingDown: ERROR: Timeout while waiting for component ***");
setverdict(inconc);
}
}
unmap(p_ptcGeoNetworking:geoNetworkingPort);
* @desc The base default.
*/
altstep a_default() runs on ItsNt {
[] geoNetworkingPort.receive {
setverdict (inconc, "Received an unexpected message");
//TODO shall stop be called here?
stop;
}
[] tc_wait.timeout {
setverdict (inconc, "Timeout while awaiting reaction of the IUT prior to Upper Tester action");
//TODO shall stop be called here?
stop;
}
[] tc_ac.timeout {
setverdict (inconc, "Timeout while awaiting the reception of a message");
//TODO shall stop be called here?
stop;
}
}
group geoGeoUnicastAltsteps {
/**
* @desc Receive GeoUnicast packet
*/
altstep a_receiveGeoUnicast(
in template (present) LongPosVector p_senderLongPosVec,
in template (present) ShortPosVector p_destinationShortPosVec,
in template (present) StationTypeIdentifier p_stationType,
in template (present) UInt16 p_seqNumber
) runs on ItsNt {
[] geoNetworkingPort.receive(mw_geoNwInd(mw_geoNwPdu(mw_geoUnicastHeader(
p_senderLongPosVec,
p_destinationShortPosVec,
p_seqNumber)))) {
}
}
/**
* @desc Receive GeoUnicast packet for specific destination
*/
altstep a_receiveGeoUnicastWithDestination(in template (present) ShortPosVector p_destinationShortPosVec) runs on ItsNt {
[] a_receiveGeoUnicast(?, p_destinationShortPosVec, ?, ?) {}
}
/**
* @desc Receive any GeoUnicast packet
*/
altstep a_receiveAnyGeoUnicast() runs on ItsNt {
[] a_receiveGeoUnicast(?, ?, ?, ?) {}
}
} // end geoGeoUnicastAltsteps
group geoLocationServiceAltsteps {
/**
* @desc Receive Location Service Request
*/
altstep a_receiveLsRequest(
in template (present) StationTypeIdentifier p_stationType,
in template (present) UInt16 p_seqNumber,
in template (present) GN_Address p_gnAddress,
out template (value) LongPosVector p_reqSrcPosVector
var GeoNetworkingInd v_msg;
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwPdu(
mw_lsRequestHeader(
p_stationType,
p_seqNumber,
p_gnAddress
)
)
)
) -> value v_msg {
p_reqSrcPosVector := v_msg.msgIn.header.lsRequestHeader.srcPosVector;
}
}
/**
* @desc Receive any Location Service Request
*/
altstep a_receiveAnyLsRequest() runs on ItsNt {
var LongPosVector v_reqSrcPosVector;
[] a_receiveLsRequest(?, ?, ?, v_reqSrcPosVector) {}
}
/**
* @desc Receive Location Service Request and send Location Service Reply
*/
altstep a_receiveLsRequestAndReply(
in template (present) StationTypeIdentifier p_reqStationType,
in template (present) UInt16 p_reqSeqNumber,
in template (value) GN_Address p_gnAddress,
in template (value) LongPosVector p_repSrcPosVector,
in template (value) LongPosVector p_repSenderPosVector,
in template (value) StationTypeIdentifier p_repStationType
var LongPosVector v_repDstPosVector;
[] a_receiveLsRequest(p_reqStationType, p_reqSeqNumber, p_gnAddress, v_repDstPosVector) {
f_sendGeoNetMessage(m_geoNwReq(m_geoNwPdu(
m_lsReplyHeader(
p_repSrcPosVector,
v_repDstPosVector,
vc_localSeqNumber
))));
}
}
} // end geoLocationServiceAltsteps
} // end geoAltsteps
group preambles {
/**
* @desc The default preamble.
*/
function f_prDefault() runs on ItsNt {
activate(a_default());
}
/**
* @desc Brings the IUT into an initial state.
* @return
*/
function f_prInitialState() runs on ItsNt {
f_prDefault();
// TODO: any specific action ?
setverdict(pass);
}
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
function f_handleLocationService(
in template (present) StationTypeIdentifier p_reqStationType,
in template (present) UInt16 p_reqSeqNumber,
in template (value) GN_Address p_gnAddress,
in template (value) LongPosVector p_repSrcPosVector,
in template (value) LongPosVector p_repSenderPosVector,
in template (value) StationTypeIdentifier p_repStationType
) runs on ItsNt {
tc_ac.start;
alt {
[] a_receiveLsRequestAndReply(p_reqStationType, p_reqSeqNumber, p_gnAddress,
p_repSrcPosVector, p_repSenderPosVector, p_repStationType) {
tc_ac.stop;
}
}
}
function f_processLocationService(
in template (value) LongPosVector p_reqSrcPosVector,
in template (value) StationTypeIdentifier p_reqStationType,
in template (value) UInt16 p_reqSeqNumber,
in template (value) GN_Address p_gnAddress,
out template (value) LongPosVector p_repSrcPosVector
) runs on ItsNt return FncRetCode {
var FncRetCode v_ret := e_error;
var GeoNetworkingInd v_msg;
f_sendGeoNetMessage(
m_geoNwReq(
m_geoNwPdu(
m_lsRequestHeader(
p_reqSrcPosVector,
p_reqSrcPosVector,
p_reqStationType,
p_reqSeqNumber,
p_gnAddress
)
)
)
);
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwPdu(
mw_lsReplyHeader(
p_reqStationType,
p_reqSeqNumber,
?,
p_reqSrcPosVector
)
)
)
) -> value v_msg {
tc_ac.stop;
p_repSrcPosVector := v_msg.msgIn.header.lsRequestHeader.srcPosVector;
v_ret := e_success;
}
}
return v_ret;
}
} // end preambles
group postambles {
/**
* @desc The default postamble.
*/
function f_poDefault() runs on ItsNt {
setverdict(pass);
}
} // end postambles
group upperTester {
function f_utGenerateIpv6Message() runs on ItsNt {
}
} // end upperTester
group testAdapter {
function f_taStartBeaconing(in template (value) Header p_beaconHeader) {
//TODO
//TODO
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
group commonFunctions {
/**
* @desc Gets the value of the lifetime in seconds.
* @return
*/
function f_getLifetimeValue(in Lifetime p_lifetime) runs on ItsNt return float {
var float v_lifetime := 0.0;
select (p_lifetime.ltBase) {
case (e_50ms) {
v_lifetime := int2float(p_lifetime.multiplier) * 0.5;
}
case (e_1s) {
v_lifetime := int2float(p_lifetime.multiplier) * 1.0;
}
case (e_10s) {
v_lifetime := int2float(p_lifetime.multiplier) * 10.0;
}
case (e_100s) {
v_lifetime := int2float(p_lifetime.multiplier) * 100.0;
}
}
return v_lifetime;
}
} // end commonFunctions
function f_sendGeoNetMessage(in GeoNetworkingReq p_geoNetReq) runs on ItsNt {
geoNetworkingPort.send(p_geoNetReq);
if (not (ischosen(p_geoNetReq.msgOut.header.shbHeader) or ischosen(p_geoNetReq.msgOut.header.beaconHeader))) {
f_setLocalSequenceNumber();
}
}
function f_getTesterLongPosVector() return LongPosVector {
//TODO
function f_getTesterGnAddress() return GN_Address {
var GN_Address v_gnAddress;
//TODO
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
/**
* @desc Sets the value of the sequence number for the next event.
* @return
*/
function f_setLocalSequenceNumber() runs on ItsNt {
vc_localSeqNumber := (vc_localSeqNumber + 1) mod c_uInt16Max; //TODO check if c_uInt16Max should be replaced by module parameter
}
} // end testerFunctions
group iutFunctions {
function f_getIutGnAddress() return GN_Address {
var GN_Address v_gnAddress;
//TODO
return v_gnAddress;
}
/**
* @desc Gets the LS retransmission timer.
* @return
*/
function f_getLSRetransmitTimer() return float {
var float v_itsGnLocationServiceRetransmitTimer := 1.0;
//TODO get the value from PIXIT or MIB
return v_itsGnLocationServiceRetransmitTimer;
}
/**
* @desc Gets the LS maximum retransmission number.
* @return
*/
function f_getLSMaxRetrans() return integer {
var integer v_itsGnLocationServiceMaxRetrans := 10;
//TODO get the value from PIXIT or MIB
return v_itsGnLocationServiceMaxRetrans;
}
/**
* @desc Gets the upper limit of the maximum lifetime.
* @return
*/
function f_getMaxPacketLifeTime() return float {
var float v_itsGnMaxPacketLifetime := 600.0;
//TODO get the value from PIXIT or MIB
return v_itsGnMaxPacketLifetime;
}
/**
* @desc Gets delta for timers.
* @return
*/
function f_getDeltaTimer() return float {
var float v_deltaTimer := 0.1;
//TODO get the value from PIXIT
return v_deltaTimer;
}
} // end iutFunctions
group neighborFunctions {
function f_getNeighborLongPosVector() return LongPosVector {
var LongPosVector v_longPosVector;
//TODO
return v_longPosVector;
}
} // end testerFunctions
group posVectorFunctions {
function f_longPosVector2ShortPosVector(in LongPosVector p_longPosVector) return ShortPosVector {
var ShortPosVector v_shortPosVector;
v_shortPosVector := {
gnAddr := p_longPosVector.gnAddr,
timestamp := p_longPosVector.timestamp,
latitute := p_longPosVector.latitute,
longitude := p_longPosVector.longitude
};
function f_getIutShortPosVector() return ShortPosVector {
var ShortPosVector v_shortPosVector;
//TODO