Loading TraceParser/MainModule.ttcn3 0 → 100644 +177 −0 Original line number Diff line number Diff line module MainModule { import from TraceParserSystem all; function f_obuBehaviour() runs on ObuType { var address ts := 0; var integer startTS := 0; var template (present) LinkId v_linkId := ?; var boolean v_receivedLinkId := false; transactionOBUTimer.start; alt { [startTS==0] obuPort.receive(mw_obuBroadCastMsg) -> sender ts { // when the first broadcast message is received then take it's time stamp transactionOBUTimer.stop; startTS := ts; transactionOBUTimer.start; repeat; } [] compPort.receive(v_linkId) -> value v_linkId{ transactionOBUTimer.stop; v_receivedLinkId := true; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_releaseMsg(v_linkId)) -> sender ts { // when the release message was received take it's time stamp and calculate the transaction time // inform the rsu component transactionOBUTimer.stop; compPort.send(m_stop); if (ts - startTS <= 100000) { setverdict (pass, "Transaction finished in " & int2str(ts - startTS)); } else { setverdict (fail, "Transaction finished in more than 100ms (" & int2str(ts - startTS) & ")"); } stop; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_msg_withLinkId(v_linkId)){ transactionOBUTimer.stop; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_obuBroadCastMsg){ //If another broadcast is received than ignore transactionOBUTimer.stop; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive { transactionOBUTimer.stop; setverdict(fail, "Unexpected message received"); compPort.send(m_stop); stop; } [] transactionOBUTimer.timeout { setverdict (inconc, "No message was received"); compPort.send(m_stop); stop; } } } function f_rsuBehaviour() runs on RsuType { var boolean v_sentLinkId := false; var PayloadStructure v_msg; var integer v_cntEmpty := 0; var template (present) LinkId v_linkId := ?; timer t_rsuTimer := 5.0; t_rsuTimer.start; alt{ []rsuPort.receive(mw_msg_withLinkId(v_linkId)) -> value v_msg{ t_rsuTimer.stop; if (v_sentLinkId == false) { v_linkId := valueof(v_msg.linkMsg.linkId); compPort.send(valueof(v_linkId)); } v_sentLinkId := true; t_rsuTimer.start; repeat; } []rsuPort.receive(mw_msg_empty){ t_rsuTimer.stop; v_cntEmpty := v_cntEmpty +1; t_rsuTimer.start; repeat; } []rsuPort.receive{ t_rsuTimer.stop; setverdict (fail, "Unexpected message received."); stop; } []compPort.receive(m_stop) { setverdict (pass, "Number of empty messages received: " & int2str(v_cntEmpty)); } []t_rsuTimer.timeout{ setverdict(inconc, "No RSU messaged received"); stop; } } } testcase TC_Initialization(inout integer p_nrOfTransactions) runs on MtcType system SystemType { map(mtc:controlPort, system:controlPort); controlPort.call(setTraceFile:{TRACE_PATH}, 5.0) { [] controlPort.getreply(setTraceFile:{-} value true) { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Could not set trace file"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while setting trace file"); stop; } }; controlPort.call(getTransactionCnt:{}, 5.0) { [] controlPort.getreply(getTransactionCnt:{} value ?) -> value p_nrOfTransactions { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Unexpected reply"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while caling getTransacationCnt"); stop; } }; } testcase TC_AnalyzesTrace(inout integer p_traceIndex) runs on MtcType system SystemType { var ObuType obuComponent := ObuType.create("OBU"); //DL var RsuType rsuComponent := RsuType.create("RSU"); //UL map(mtc:controlPort, system:controlPort); map(obuComponent:obuPort, system:msgPort); map(rsuComponent:rsuPort, system:msgPort); connect(obuComponent:compPort, rsuComponent:compPort); obuComponent.start(f_obuBehaviour()); rsuComponent.start(f_rsuBehaviour()); log ("Starting analysis of trace: ", p_traceIndex); controlPort.call(startAnalyzeTrace:{p_traceIndex}, 5.0) { [] controlPort.getreply(startAnalyzeTrace:{-} value true) { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Could not start analyzing trace"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while start analyzing trace"); stop; } }; all component.done; } control { var integer v_nrOfTransactions := 0; execute(TC_Initialization(v_nrOfTransactions)); log("Number of traces: " , v_nrOfTransactions); for(var integer i:=0; i<v_nrOfTransactions; i:=i + 1) { execute(TC_AnalyzesTrace(i)); } } } No newline at end of file TraceParser/TraceParserSystem.ttcn3 0 → 100644 +140 −0 Original line number Diff line number Diff line module TraceParserSystem { modulepar charstring TRACE_PATH:= "C:\Demo_Dump2.txt"; type port TraceMsgPortType message{ in PayloadStructure; } type port TraceCtrlPortType procedure{ out setTraceFile, getTransactionCnt, startAnalyzeTrace, finishAnalyzeTrace } type port CompPortType message{ inout LinkId, SyncCommand; } type component SystemType { port TraceCtrlPortType controlPort; port TraceMsgPortType msgPort; } type component MtcType { port TraceCtrlPortType controlPort; timer transactionTimer := 5.0 ; } /** * @desc Defines a component type that will be used later as mtc */ type component ObuType { //downLinkType port TraceMsgPortType obuPort; port CompPortType compPort; timer transactionOBUTimer := 1.0 ; } type component RsuType { //upLinkType port TraceMsgPortType rsuPort; port CompPortType compPort; timer transactionRSUTimer := 1.0 ; } group payloadTypes { type octetstring LinkId length(4); type union PayloadStructure { BroadcastMsg broadcastMsg, LinkMsg linkMsg } type record BroadcastMsg { octetstring broadcast ('FF'O) length(1), octetstring msg } type record LinkMsg { LinkId linkId optional, octetstring macControl length(1) optional, octetstring linkControl length(1) optional, octetstring fragHeader length(1) optional, octetstring tapdu length(1..117) optional } } with { encode "TraceMessages" } type enumerated SyncCommand { e_stop, e_error } template PayloadStructure mw_obuBroadCastMsg := { broadcastMsg := { broadcast := 'FF'O, msg := ? } } template PayloadStructure mw_releaseMsg(template (present) LinkId p_linkId) :={ linkMsg := { linkId := p_linkId, macControl := '80'O, linkControl := ?, fragHeader := ?, tapdu := '200000'O } } template PayloadStructure mw_msg_withLinkId(template (present) LinkId p_linkId) :={ linkMsg := { linkId := p_linkId, macControl := *, linkControl := *, fragHeader := *, tapdu := * } } template PayloadStructure mw_msg_empty :={ linkMsg := { linkId := omit, macControl := omit, linkControl := omit, fragHeader := omit, tapdu := omit } } template SyncCommand m_stop := e_stop; group baseMessages { type integer address; } with { encode "BaseMessages" } group signatures { signature setTraceFile(in charstring tracePath) return boolean; signature isFolder() return boolean; signature getTransactionCnt() return integer; signature startAnalyzeTrace(in integer transactionCnt) return boolean; signature finishAnalyzeTrace() return boolean; } with { encode "Signatures" } } No newline at end of file Loading
TraceParser/MainModule.ttcn3 0 → 100644 +177 −0 Original line number Diff line number Diff line module MainModule { import from TraceParserSystem all; function f_obuBehaviour() runs on ObuType { var address ts := 0; var integer startTS := 0; var template (present) LinkId v_linkId := ?; var boolean v_receivedLinkId := false; transactionOBUTimer.start; alt { [startTS==0] obuPort.receive(mw_obuBroadCastMsg) -> sender ts { // when the first broadcast message is received then take it's time stamp transactionOBUTimer.stop; startTS := ts; transactionOBUTimer.start; repeat; } [] compPort.receive(v_linkId) -> value v_linkId{ transactionOBUTimer.stop; v_receivedLinkId := true; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_releaseMsg(v_linkId)) -> sender ts { // when the release message was received take it's time stamp and calculate the transaction time // inform the rsu component transactionOBUTimer.stop; compPort.send(m_stop); if (ts - startTS <= 100000) { setverdict (pass, "Transaction finished in " & int2str(ts - startTS)); } else { setverdict (fail, "Transaction finished in more than 100ms (" & int2str(ts - startTS) & ")"); } stop; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_msg_withLinkId(v_linkId)){ transactionOBUTimer.stop; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_obuBroadCastMsg){ //If another broadcast is received than ignore transactionOBUTimer.stop; transactionOBUTimer.start; repeat; } [startTS!=0 and v_receivedLinkId == true] obuPort.receive { transactionOBUTimer.stop; setverdict(fail, "Unexpected message received"); compPort.send(m_stop); stop; } [] transactionOBUTimer.timeout { setverdict (inconc, "No message was received"); compPort.send(m_stop); stop; } } } function f_rsuBehaviour() runs on RsuType { var boolean v_sentLinkId := false; var PayloadStructure v_msg; var integer v_cntEmpty := 0; var template (present) LinkId v_linkId := ?; timer t_rsuTimer := 5.0; t_rsuTimer.start; alt{ []rsuPort.receive(mw_msg_withLinkId(v_linkId)) -> value v_msg{ t_rsuTimer.stop; if (v_sentLinkId == false) { v_linkId := valueof(v_msg.linkMsg.linkId); compPort.send(valueof(v_linkId)); } v_sentLinkId := true; t_rsuTimer.start; repeat; } []rsuPort.receive(mw_msg_empty){ t_rsuTimer.stop; v_cntEmpty := v_cntEmpty +1; t_rsuTimer.start; repeat; } []rsuPort.receive{ t_rsuTimer.stop; setverdict (fail, "Unexpected message received."); stop; } []compPort.receive(m_stop) { setverdict (pass, "Number of empty messages received: " & int2str(v_cntEmpty)); } []t_rsuTimer.timeout{ setverdict(inconc, "No RSU messaged received"); stop; } } } testcase TC_Initialization(inout integer p_nrOfTransactions) runs on MtcType system SystemType { map(mtc:controlPort, system:controlPort); controlPort.call(setTraceFile:{TRACE_PATH}, 5.0) { [] controlPort.getreply(setTraceFile:{-} value true) { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Could not set trace file"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while setting trace file"); stop; } }; controlPort.call(getTransactionCnt:{}, 5.0) { [] controlPort.getreply(getTransactionCnt:{} value ?) -> value p_nrOfTransactions { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Unexpected reply"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while caling getTransacationCnt"); stop; } }; } testcase TC_AnalyzesTrace(inout integer p_traceIndex) runs on MtcType system SystemType { var ObuType obuComponent := ObuType.create("OBU"); //DL var RsuType rsuComponent := RsuType.create("RSU"); //UL map(mtc:controlPort, system:controlPort); map(obuComponent:obuPort, system:msgPort); map(rsuComponent:rsuPort, system:msgPort); connect(obuComponent:compPort, rsuComponent:compPort); obuComponent.start(f_obuBehaviour()); rsuComponent.start(f_rsuBehaviour()); log ("Starting analysis of trace: ", p_traceIndex); controlPort.call(startAnalyzeTrace:{p_traceIndex}, 5.0) { [] controlPort.getreply(startAnalyzeTrace:{-} value true) { setverdict (pass); } [] controlPort.getreply { setverdict (fail, "Could not start analyzing trace"); stop; } [] controlPort.catch(timeout) { setverdict (fail, "Timeout while start analyzing trace"); stop; } }; all component.done; } control { var integer v_nrOfTransactions := 0; execute(TC_Initialization(v_nrOfTransactions)); log("Number of traces: " , v_nrOfTransactions); for(var integer i:=0; i<v_nrOfTransactions; i:=i + 1) { execute(TC_AnalyzesTrace(i)); } } } No newline at end of file
TraceParser/TraceParserSystem.ttcn3 0 → 100644 +140 −0 Original line number Diff line number Diff line module TraceParserSystem { modulepar charstring TRACE_PATH:= "C:\Demo_Dump2.txt"; type port TraceMsgPortType message{ in PayloadStructure; } type port TraceCtrlPortType procedure{ out setTraceFile, getTransactionCnt, startAnalyzeTrace, finishAnalyzeTrace } type port CompPortType message{ inout LinkId, SyncCommand; } type component SystemType { port TraceCtrlPortType controlPort; port TraceMsgPortType msgPort; } type component MtcType { port TraceCtrlPortType controlPort; timer transactionTimer := 5.0 ; } /** * @desc Defines a component type that will be used later as mtc */ type component ObuType { //downLinkType port TraceMsgPortType obuPort; port CompPortType compPort; timer transactionOBUTimer := 1.0 ; } type component RsuType { //upLinkType port TraceMsgPortType rsuPort; port CompPortType compPort; timer transactionRSUTimer := 1.0 ; } group payloadTypes { type octetstring LinkId length(4); type union PayloadStructure { BroadcastMsg broadcastMsg, LinkMsg linkMsg } type record BroadcastMsg { octetstring broadcast ('FF'O) length(1), octetstring msg } type record LinkMsg { LinkId linkId optional, octetstring macControl length(1) optional, octetstring linkControl length(1) optional, octetstring fragHeader length(1) optional, octetstring tapdu length(1..117) optional } } with { encode "TraceMessages" } type enumerated SyncCommand { e_stop, e_error } template PayloadStructure mw_obuBroadCastMsg := { broadcastMsg := { broadcast := 'FF'O, msg := ? } } template PayloadStructure mw_releaseMsg(template (present) LinkId p_linkId) :={ linkMsg := { linkId := p_linkId, macControl := '80'O, linkControl := ?, fragHeader := ?, tapdu := '200000'O } } template PayloadStructure mw_msg_withLinkId(template (present) LinkId p_linkId) :={ linkMsg := { linkId := p_linkId, macControl := *, linkControl := *, fragHeader := *, tapdu := * } } template PayloadStructure mw_msg_empty :={ linkMsg := { linkId := omit, macControl := omit, linkControl := omit, fragHeader := omit, tapdu := omit } } template SyncCommand m_stop := e_stop; group baseMessages { type integer address; } with { encode "BaseMessages" } group signatures { signature setTraceFile(in charstring tracePath) return boolean; signature isFolder() return boolean; signature getTransactionCnt() return integer; signature startAnalyzeTrace(in integer transactionCnt) return boolean; signature finishAnalyzeTrace() return boolean; } with { encode "Signatures" } } No newline at end of file