This is an implementation of CDTA server that handles the aggregation of MVoTs from local DTMCs.
/MVoT
- POST
/MVoT- DTMCs post their respective MVoT to
MVoTendpoint to update the CDTA of changes to their trust calculations. - Body of request should be validated to contain:
anon_id: anonymized ID of DER for that service- If the DTMC does not have this, it should use the default
*-*-*-*ID (all anonymized)
- If the DTMC does not have this, it should use the default
registration_date: date of device registrationlast_timestamp: timestamp of last messagesdtt: standard deviation of transit timeRFC: relative factor of certaintyTSLC: time since last communicationtx_time: transit timecomm_freq: communication frequencycertainty: current certainty levelavg_tx_time: average transit timetrust_score: current trust scoredistrust_score: current distrust scoretotal_msgs: total number of messagesother_count: count of other actionsalerts_count: count of alertstimeout_count: count of timeoutscount_expected_msgs: count of expected messagescount_unexpected_msgs: count of unexpected messages
- Response: status code
200if message validation passes and insertion was successful400if request validation failed500otherwise
- DTMCs post their respective MVoT to
- GET
/MVoT- Returns recent MVoT data for all DTMCs for the purposes of plotting current trust level/dashboard app
- Body of request should be empty
- Response: XML list of latest MVoT entries from each DTMC
To install dependencies, use: pip3 install -r requirements.txt
To seed the DB, use init_db.py script. To do so, run: python3 init_db.py
To run the server, use: python3 CDTA.py
This runs an HTTP server on port 80. This should be changed to port 443 when self-signed certificate support is setup.
Might need to use
sudowhen running the server depending on the OS
To run the tests, run: python3 -m unittest test_api.py
The tests involve testing both available methods (GET/POST) for
/MVoTendpoint.
- POST
/MVoT
The following is an example of what the XML format expected for a POST request on the endpoint
<?xml version='1.0'?>
<MVoT>
<anon_id>substation0:segment7:xformer2:DER 40-50</anon_id>
<registration_date>1629393715.096357</registration_date>
<last_timestamp>1629394315.096386</last_timestamp>
<sdtt>0.1112444366039249</sdtt>
<RFC>1.0</RFC>
<TSLC>300.00001287460327</TSLC>
<tx_time>0.17</tx_time>
<comm_freq>0.0049999997595946</comm_freq>
<certainty>0.0002321533514997</certainty>
<avg_tx_time>0.131038961038961</avg_tx_time>
<trust_score>0.0006344171455322</trust_score>
<distrust_score>0.0</distrust_score>
<total_msgs>3</total_msgs>
<other_count>0</other_count>
<alerts_count>0</alerts_count>
<timeout_count>0</timeout_count>
<count_expected_msgs>3</count_expected_msgs>
<count_unexpected_msgs>0</count_unexpected_msgs>
</MVoT>
- GET
/MVoT
The following is an example of what the CDTA returns of GET request on the endpoint
<?xml version="1.0" ?>
<MVoTs>
<MVoT>
<mvot_id>1302</mvot_id>
<anon_id>*:*:*:*</anon_id>
<registration_date>1629393715.096362</registration_date>
<last_timestamp>1629537715.103173</last_timestamp>
<sdtt>0.0108067067597848</sdtt>
<RFC>1.0</RFC>
<TSLC>300.00001192092896</TSLC>
<tx_time>0.34</tx_time>
<comm_freq>0.0033402776197895</comm_freq>
<certainty>0.0011134258289796</certainty>
<avg_tx_time>0.2538750830835711</avg_tx_time>
<trust_score>0.5355601460814438</trust_score>
<distrust_score>0.0</distrust_score>
<total_msgs>481</total_msgs>
<other_count>0</other_count>
<alerts_count>0</alerts_count>
<timeout_count>0</timeout_count>
<count_expected_msgs>481</count_expected_msgs>
<count_unexpected_msgs>0</count_unexpected_msgs>
</MVoT>
....
<MVoT>
<mvot_id>1924</mvot_id>
<anon_id>*:*:*:*</anon_id>
<registration_date>1629393715.096365</registration_date>
<last_timestamp>1629537715.103177</last_timestamp>
<sdtt>0.0112319018613085</sdtt>
<RFC>1.0</RFC>
<TSLC>300.00001311302185</TSLC>
<tx_time>0.25</tx_time>
<comm_freq>0.0033402776197618</comm_freq>
<certainty>0.001113425824546</certainty>
<avg_tx_time>0.2441793344732304</avg_tx_time>
<trust_score>0.5355601465070687</trust_score>
<distrust_score>0.0</distrust_score>
<total_msgs>481</total_msgs>
<other_count>0</other_count>
<alerts_count>0</alerts_count>
<timeout_count>0</timeout_count>
<count_expected_msgs>481</count_expected_msgs>
<count_unexpected_msgs>0</count_unexpected_msgs>
</MVoT>
</MVoTs>