ot-ns icon indicating copy to clipboard operation
ot-ns copied to clipboard

[Simulation] Add energy analysis with exporting commands and chart visualization

Open Vinggui opened this issue 2 years ago • 15 comments

Contribution description

This PR adds energy analysis (including charts), transmission timings, and collision analysis support to the OTNS. It is, however, compatible with the current version of the Openthread/Openthread simulated device.

This PR also introduces:

  • A new CLI called energy save [output name], allowing the user to store the energy results obtained out of their simulation;
  • A new button called "Open Charts" in the Action bar of the web interface. It opens a new browser tab which does not interfere with the PIXI interface. This tab contains 3 charts: Energy consumption history, energy consumption by radio state and node ID, and power consumption.

This energy simulation is based on the STM32WB55rg at 3.3V:

	RadioDisabledConsumption float64 = 0.00011 //To be confirmed
	RadioTxConsumption       float64 = 0.01716 //5.2 mA
	RadioRxConsumption       float64 = 0.01485 //4.5 mA
	RadioIdleConsumption     float64 = 0.01485 //4.5 mA

Main modifications

  • A new energy analysis module (Go);
  • An extended PROTO service that provides a streaming API to the new char tab;
  • A new HTML file using Chart.js and the extended gRPC service;
  • Some re-wiring on the existent go modules, to include the energy analysis module;
  • New event type providing TxDone callbacks that consider transmission times to the simulated device;
  • New style of simplelogger.Debugf "status push", showing the simulated time;
  • New event type that allows simulated devices to do Clear Channel Assessment (with future possibility to provide scanning and RSSI model into the simulation);
  • New event type eventTypeRadioComm = 6 that will substitute eventTypeRadioReceived = 1. At the moment, both types are used to keep compatibility between the new changes of PR #7500 and the current OpenThread version, respectively.

Needs check/review

I believe that the modifications should not impact any other OTNS' functionalities, but I could not yet test some of them, for example:

  • Real devices integrated to the simulator;
  • Replay;
  • Python commands.

If you please have easy access to it, send me feedback.

Requirements

None (if intended to be used with current Openthread repository). But, there is another PR #7500 in Openthread repository that allows all the new features in the simulation to work.

Testing procedure

Just install OTNS the same way as before, using the "OTNS=1" for the building parameter.

To obtain the energy results, just use the command energy save, but if you want a specific name for the files, use energy save "name"

Vinggui avatar Mar 23 '22 00:03 Vinggui

This pull request introduces 3 alerts and fixes 1 when merging 1e0f32687ba8d4845e23a2417a229aa650be7bff into 941d6e289801fb1ba58e9a533bbb80fbeffe0d80 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class
  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 23 '22 00:03 lgtm-com[bot]

This pull request introduces 1 alert and fixes 1 when merging 50adc82e664b6b604b4ba9846b631d6c96018312 into 941d6e289801fb1ba58e9a533bbb80fbeffe0d80 - view on LGTM.com

new alerts:

  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 23 '22 02:03 lgtm-com[bot]

I'm having some problems with the gRPC module pushed into this PR. I had it changed and updated here in the commits, but it seems like the CI/CD is having problems: "no matching versions for query "latest". How can I fix this case and let the rest of the tests execute?

Vinggui avatar Mar 23 '22 03:03 Vinggui

This pull request introduces 1 alert and fixes 1 when merging 725825757faca285a2fd205d1f11a09579e14aa2 into 941d6e289801fb1ba58e9a533bbb80fbeffe0d80 - view on LGTM.com

new alerts:

  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 29 '22 04:03 lgtm-com[bot]

This pull request introduces 1 alert and fixes 1 when merging 3e23d292c9fdc017f2594749ff894a80d88a50e0 into 8da999ec4768e20627e579f2c6c605bbaa16ea36 - view on LGTM.com

new alerts:

  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 30 '22 22:03 lgtm-com[bot]

This pull request introduces 1 alert and fixes 1 when merging ad023acc52281488e651648dbb53feda5fbf1665 into 8da999ec4768e20627e579f2c6c605bbaa16ea36 - view on LGTM.com

new alerts:

  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 30 '22 23:03 lgtm-com[bot]

This pull request introduces 1 alert and fixes 1 when merging c642beb14d52509f0deaead0bf9654167102673b into 8da999ec4768e20627e579f2c6c605bbaa16ea36 - view on LGTM.com

new alerts:

  • 1 for Reflected cross-site scripting

fixed alerts:

  • 1 for Incorrect conversion between integer types

lgtm-com[bot] avatar Mar 31 '22 07:03 lgtm-com[bot]

I realized one big problem in this simulated energy measurements: the transmission times are not simulated. So, we don't get the right timing spent on transmission state.

Update: @simonlingoogle, I got transmission timing working, and collision model implemented too. Please, consider reviewing again both PR #7500 and this one. I think I made a good contribution here.

Vinggui avatar Mar 31 '22 07:03 Vinggui

Codecov Report

Merging #235 (a7729bb) into main (7d96f58) will decrease coverage by 3.80%. The diff coverage is 11.31%.

@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
- Coverage   49.93%   46.12%   -3.81%     
==========================================
  Files          38       40       +2     
  Lines        4604     5058     +454     
==========================================
+ Hits         2299     2333      +34     
- Misses       2123     2535     +412     
- Partials      182      190       +8     
Impacted Files Coverage Δ
cli/CmdRunner.go 22.62% <0.00%> (-0.51%) :arrow_down:
cli/ast.go 66.66% <ø> (ø)
types/types.go 65.38% <ø> (ø)
visualize/grpc/grpcStream.go 50.00% <0.00%> (-50.00%) :arrow_down:
visualize/multi/multiVisualizer.go 0.00% <0.00%> (ø)
visualize/nopVisualizer.go 50.00% <ø> (ø)
visualize/types.go 17.39% <ø> (ø)
web/site/bindata.go 99.01% <ø> (+0.01%) :arrow_up:
visualize/grpc/pb/visualize_grpc.pb.go 18.00% <1.92%> (-1.42%) :arrow_down:
dispatcher/dispatcher.go 48.22% <5.26%> (-8.88%) :arrow_down:
... and 10 more

codecov-commenter avatar May 07 '22 18:05 codecov-commenter

This pull request introduces 2 alerts when merging eb6d5453f341636033ef69f331b484651d613b98 into 8b7655fe3802517088627e63d0f632f2460d700c - view on LGTM.com

new alerts:

  • 1 for Incorrect conversion between integer types
  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar May 07 '22 18:05 lgtm-com[bot]

This pull request fixes 1 alert when merging 0bc53184da9c75567210355bd70f9add7de443ae into 8b7655fe3802517088627e63d0f632f2460d700c - view on LGTM.com

fixed alerts:

  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar May 07 '22 19:05 lgtm-com[bot]

This pull request fixes 1 alert when merging a7729bb36546326e93ef2358ebf7bea53b0b2d4c into 7d96f58562110ed87969ff38dfac7f4f31e61170 - view on LGTM.com

fixed alerts:

  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar May 09 '22 19:05 lgtm-com[bot]

This pull request fixes 1 alert when merging 31e9e066e17a324e42e532775ad9157ec13dac10 into 4616010a378cc0598a1f31e1192b530d936f1c74 - view on LGTM.com

fixed alerts:

  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar Jun 30 '22 16:06 lgtm-com[bot]

This pull request fixes 1 alert when merging c3a61f8d56c95cca978d153f2567de8d3b7d06bc into 0ab74442895d53828801f01baeec98c2579d4365 - view on LGTM.com

fixed alerts:

  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar Sep 19 '22 17:09 lgtm-com[bot]

This pull request fixes 1 alert when merging ae7a872560214377627f69759fbe1d2aadcaab49 into 0ab74442895d53828801f01baeec98c2579d4365 - view on LGTM.com

fixed alerts:

  • 1 for Reflected cross-site scripting

lgtm-com[bot] avatar Sep 19 '22 19:09 lgtm-com[bot]