The OTNS CLI exposes configuration and management APIs via a command line interface. Use the CLI to control OTNS or use it directly in additional application code. For example, the OTNS Python libraries use the CLI to manage simulations.
- add
- coaps
- counters
- cv
- del
- exit
- go
- joins
- move
- netinfo
- node
- nodes
- partitions (pts)
- ping
- pings
- plr
- radio
- scan
- speed
- title
- web
Add a node to the simulation and get the node ID. Node ID can be specified, otherwise OTNS assigns the next available one.
If restore
option is specified, the node restores its network configuration from persistent storage.
> add router
1
Done
> add fed x 100 y 100
2
Done
> add med x 100 y 200 rr 200
3
Done
> add sed x 200 y 200 rr 400
4
Done
> add sed x 200 y 200 restore
5
Done
> add fed x 200 y 200 id 25
25
Done
Enable collecting info of CoAP messages.
> coaps enable
Done
Show info of collected CoAP messages in yaml format.
> coaps
- {time: 57019000, src: 2, id: 25421, type: 0, code: 2, uri: a/as, dst_addr: 'fdde:ad00:beef:0:0:ff:fe00:f000', dst_port: 61631, receivers: [{time: 57019961, dst: 1, src_addr: 'fdde:ad00:beef:0:0:ff:fe00:f001', src_port: 61631}]}
- {time: 57019961, src: 1, id: 25421, type: 2, code: 68, dst_addr: 'fdde:ad00:beef:0:0:ff:fe00:f001', dst_port: 61631, receivers: [{time: 57021242, dst: 2, src_addr: 'fdde:ad00:beef:0:0:ff:fe00:f000', src_port: 61631}]}
Done
Display runtime counters.
> counters
AlarmEvents 95983
RadioEvents 1674
StatusPushEvents 47
DispatchByExtAddrSucc 239
DispatchByExtAddrFail 0
DispatchByShortAddrSucc 188
DispatchByShortAddrFail 0
DispatchAllInRange 0
Done
Configure visualization options.
Visualization Options:
- bro: broadcast message
- uni: unicast message
- ack: ACK message
- rtb: router table
- ctb: child table
> cv
bro=on
uni=on
ack=off
rtb=on
ctb=on
Done
> cv bro off
bro=off
uni=on
ack=off
rtb=on
ctb=on
Done
> cv bro on uni on ack on rtb on ctb on
bro=on
uni=on
ack=on
rtb=on
ctb=on
Done
Delete nodes by ID.
> del 1
Done
> del 1 2 3
Done
Exit OTNS.
> exit
Done
<EOF>
Simulate for a specified time in seconds or indefinitely (ever
). Only required in -autogo=false
mode
> go 1
Done
> go 10
Done
> go ever
<NEVER FINISHES>
Connect finished joiner sessions.
> joins
node=2 join=4.899s session=5.000s
Done
Move a node to the target position.
> move 1 200 300
Done
Set netowrk info.
> netinfo version "Latest"
Done
> netinfo version "Latest" commit "b49ee08"
Done
> netinfo real y
Done
Run an OpenThread CLI command on a specific node.
> node 1 "state"
leader
Done
List nodes.
> nodes
id=1 extaddr=62cfcf3c5556ac7c rloc16=c000 x=200 y=300 failed=false
id=2 extaddr=6a7d9d31e3511147 rloc16=3000 x=278 y=708 failed=false
id=3 extaddr=266db93fad653782 rloc16=2800 x=207 y=666 failed=false
Done
List partitions.
> partitions
partition=4683661d nodes=4,1,3
partition=7cb22d3b nodes=2
Done
> pts
partition=7cb22d3b nodes=2
partition=4683661d nodes=1,3,4
Done
ping <src-id> [<dst-id> [<addr-type>] | "<dst-addr>" ] [datasize <datasize>] [count <count>] [interval <interval>] [hoplimit <hoplimit>]
Ping from the source node to a destination (another node or an IPv6 address).
> ping 1 2
Done
> ping 1 2 rloc
Done
> ping 1 2 mleid
Done
> ping 1 "fdde:ad00:beef:0:31d6:8873:f685:9c40"
Done
> ping 1 2 datasize 10 count 3 interval 1 hoplimit 10
Done
Display finished ping sessions.
> ping 1 2 count 3
Done
> pings
node=1 dst=fdde:ad00:beef:0:31d6:8873:f685:9c40 datasize=4 delay=0.322ms
node=1 dst=fdde:ad00:beef:0:31d6:8873:f685:9c40 datasize=4 delay=2.242ms
node=1 dst=fdde:ad00:beef:0:31d6:8873:f685:9c40 datasize=4 delay=1.282ms
Done
Get the global packet loss ratio
> plr
0
Done
Set the global packet loss ratio
> plr 0.5
0.5
Done
Set the radio on/off/fail time parameters in seconds.
> radio 1 off
Done
> radio 1 on
Done
> radio 1 2 3 off
Done
> radio 1 2 3 on
Done
> radio 1 2 3 ft 10 60
Done
ft 10 60
means the nodes' radio will on average be non-functional for 10 seconds every 60 seconds.
Perform a network scan.
> scan 2
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
+---+------------------+------------------+------+------------------+----+-----+-----+
| 0 | OpenThread | dead00beef00cafe | face | 66c6bfef495534af | 11 | -20 | 0 |
Done
Get the simulating speed.
> speed
8
Done
Set the simulating speed.
> speed 10
Done
> speed
10
Done
Set maximum simulating speed.
> speed max
Done
> speed
1e+06
Done
> speed inf
Done
> speed
1e+06
Done
Set simulation title.
> title "Example"
Done
Set simulation title at specified position.
> title "Example" x 100 y 200
Done
Set simulation title with specified font size.
> title "Example" fs 30
Done
Open a web browser for visualization.
> web
Done