cli

package
v0.0.0-...-03c5170 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2023 License: BSD-3-Clause Imports: 19 Imported by: 0

README

OTNS CLI Reference

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.

OTNS command list

OTNS command reference

add <type> [x <x>] [y <y>] [rr <radio-range>] [id <node-id>] [restore]

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
coaps enable

Enable collecting info of CoAP messages.

> coaps enable
Done
coaps

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
counters

Display runtime counters.

> counters
AlarmEvents                              95983
RadioEvents                              1674
StatusPushEvents                         47
DispatchByExtAddrSucc                    239
DispatchByExtAddrFail                    0
DispatchByShortAddrSucc                  188
DispatchByShortAddrFail                  0
DispatchAllInRange                       0
Done
cv [<option> on|off] ...

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
del <node-id> [ ...]

Delete nodes by ID.

> del 1
Done
> del 1 2 3
Done
exit

Exit OTNS.

> exit
Done
<EOF>
go [<duration-seconds> | ever]

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>
joins

Connect finished joiner sessions.

> joins
node=2    join=4.899s session=5.000s
Done
move <node-id> <x> <y>

Move a node to the target position.

> move 1 200 300
Done
netinfo [version "<string>"] [commit "<string>"] [real y|n]

Set netowrk info.

> netinfo version "Latest"
Done
> netinfo version "Latest" commit "b49ee08"
Done
> netinfo real y
Done
node <node-id> "<command>"

Run an OpenThread CLI command on a specific node.

> node 1 "state"
leader
Done
nodes

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
partitions (pts)

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
pings

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
plr

Get the global packet loss ratio

> plr 
0
Done
plr <plr>

Set the global packet loss ratio

> plr 0.5
0.5
Done
radio <node-id> [ ...] [on | off | ft <fail-duration> <fail-interval>]

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.

scan <node-id>

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
speed

Get the simulating speed.

> speed
8
Done
speed <speed>

Set the simulating speed.

> speed 10
Done
> speed
10
Done
speed (max | inf)

Set maximum simulating speed.

> speed max
Done
> speed
1e+06
Done
> speed inf
Done
> speed
1e+06
Done
title "<string>"

Set simulation title.

> title "Example"
Done
title "<string>" [x <int>] [y <int>]

Set simulation title at specified position.

> title "Example" x 100 y 200
Done
title "<string>" [fs <int>]

Set simulation title with specified font size.

> title "Example" fs 30
Done
web

Open a web browser for visualization.

> web
Done

Documentation

Index

Constants

View Source
const (
	Prompt = "> "
)

Variables

This section is empty.

Functions

func ParseBytes

func ParseBytes(b []byte, cmd *Command) error

func Run

func Run(cr *CmdRunner, cliOptions *runcli.CliOptions) error

Types

type AddCmd

type AddCmd struct {
	Cmd        struct{}        `"add"`                //nolint
	Type       NodeType        `@@`                   //nolint
	X          *int            `( "x" (@Int|@Float) ` //nolint
	Y          *int            `| "y" (@Int|@Float) ` //nolint
	Id         *AddNodeId      `| @@`                 //nolint
	RadioRange *RadioRangeFlag `| @@`                 //nolint
	Restore    *RestoreFlag    `| @@`                 //nolint
	Executable *ExecutableFlag `| @@ )*`              //nolint
}

noinspection GoStructTag

type AddNodeId

type AddNodeId struct {
	Val int `"id" @Int` //nolint
}

noinspection GoStructTag

type AddrTypeFlag

type AddrTypeFlag struct {
	Type AddrType `@( "any" | "mleid" | "rloc" | "aloc" | "linklocal" )` //nolint
}

noinspection GoStructTag

type CVAckMessage

type CVAckMessage struct {
	Flag    struct{}    `"ack"` //nolint
	OnOrOff OnOrOffFlag `@@`    //nolint
}

noinspection GoStructTag

type CVBroadcastMessage

type CVBroadcastMessage struct {
	Flag    struct{}    `"bro"` //nolint
	OnOrOff OnOrOffFlag `@@`    //nolint
}

noinspection GoStructTag

type CVChildTable

type CVChildTable struct {
	Flag    struct{}    `"ctb"` //nolint
	OnOrOff OnOrOffFlag `@@`    //nolint
}

noinspection GoStructTag

type CVRouterTable

type CVRouterTable struct {
	Flag    struct{}    `"rtb"` //nolint
	OnOrOff OnOrOffFlag `@@`    //nolint
}

noinspection GoStructTag

type CVUnicastMessage

type CVUnicastMessage struct {
	Flag    struct{}    `"uni"` //nolint
	OnOrOff OnOrOffFlag `@@`    //nolint
}

noinspection GoStructTag

type CmdRunner

type CmdRunner struct {
	// contains filtered or unexported fields
}

func NewCmdRunner

func NewCmdRunner(ctx *progctx.ProgCtx, sim *simulation.Simulation) *CmdRunner

func (*CmdRunner) GetPrompt

func (rt *CmdRunner) GetPrompt() string

func (*CmdRunner) HandleCommand

func (rt *CmdRunner) HandleCommand(cmdline string, output io.Writer) error

func (*CmdRunner) RunCommand

func (rt *CmdRunner) RunCommand(cmdline string, output io.Writer) error

type CoapsCmd

type CoapsCmd struct {
	Cmd    struct{}    `"coaps"` //nolint
	Enable *EnableFlag `@@ ?`    //nolint
}

noinspection GoStructTag

type Command

type Command struct {
	Add                 *AddCmd                 `  @@` //nolint
	Coaps               *CoapsCmd               `| @@` //nolint
	ConfigVisualization *ConfigVisualizationCmd `| @@` //nolint
	CountDown           *CountDownCmd           `| @@` //nolint
	Counters            *CountersCmd            `| @@` //nolint
	Debug               *DebugCmd               `| @@` //nolint
	Del                 *DelCmd                 `| @@` //nolint
	DemoLegend          *DemoLegendCmd          `| @@` //nolint
	Exit                *ExitCmd                `| @@` //nolint
	Go                  *GoCmd                  `| @@` //nolint
	Joins               *JoinsCmd               `| @@` //nolint
	Move                *Move                   `| @@` //nolint
	NetInfo             *NetInfoCmd             `| @@` //nolint
	Node                *NodeCmd                `| @@` //nolint
	Nodes               *NodesCmd               `| @@` //nolint
	Partitions          *PartitionsCmd          `| @@` //nolint
	Ping                *PingCmd                `| @@` //nolint
	Pings               *PingsCmd               `| @@` //nolint
	Plr                 *PlrCmd                 `| @@` //nolint
	Radio               *RadioCmd               `| @@` //nolint
	Scan                *ScanCmd                `| @@` //nolint
	Speed               *SpeedCmd               `| @@` //nolint
	Title               *TitleCmd               `| @@` //nolint
	Web                 *WebCmd                 `| @@` //nolint
}

noinspection GoStructTag

type CommandContext

type CommandContext struct {
	context.Context
	*Command
	// contains filtered or unexported fields
}

func (*CommandContext) Err

func (cc *CommandContext) Err() error

type ConfigVisualizationCmd

type ConfigVisualizationCmd struct {
	Cmd              struct{}            `"cv"`    //nolint
	BroadcastMessage *CVBroadcastMessage `( @@`    //nolint
	UnicastMessage   *CVUnicastMessage   `| @@`    //nolint
	AckMessage       *CVAckMessage       `| @@`    //nolint
	RouterTable      *CVRouterTable      `| @@`    //nolint
	ChildTable       *CVChildTable       `| @@ )*` //nolint
}

noinspection GoStructTag

type CountDownCmd

type CountDownCmd struct {
	Cmd     struct{} `"countdown"` //nolint
	Seconds int      `@Int`        //nolint
	Text    *string  `[ @String ]` //nolint
}

noinspection GoStructTag

type CountFlag

type CountFlag struct {
	Val int `("count" | "c") @Int` //nolint
}

noinspection GoStructTag

type CountersCmd

type CountersCmd struct {
	Cmd struct{} `"counters"` //nolint
}

noinspection GoStructTag

type DataSizeFlag

type DataSizeFlag struct {
	Val int `("datasize"|"ds") @Int` //nolint
}

noinspection GoStructTag

type DebugCmd

type DebugCmd struct {
	Cmd  struct{} `"debug"`            //nolint
	Fail *string  `[ @"fail" ]`        //nolint
	Echo *string  `[ "echo" @String ]` //nolint
}

noinspection GoStructTag

type DelCmd

type DelCmd struct {
	Cmd   struct{}       `"del"`   //nolint
	Nodes []NodeSelector `( @@ )+` //nolint
}

noinspection GoStructTag

type DemoLegendCmd

type DemoLegendCmd struct {
	Cmd   struct{} `"demo_legend"` //nolint
	Title string   `@String`       //nolint
	X     int      `@Int`          //nolint
	Y     int      `@Int`          //nolint
}

noinspection GoStructTag

type Empty

type Empty struct {
	Empty struct{} `""` //nolint
}

noinspection GoStructTag

type EnableFlag

type EnableFlag struct {
	Dummy struct{} `"enable"` //nolint
}

type EverFlag

type EverFlag struct {
	Dummy struct{} `"ever"` //nolint
}

noinspection GoStructTag

type ExecutableFlag

type ExecutableFlag struct {
	Dummy struct{} `"exe"`   //nolint
	Path  string   `@String` //nolint
}

noinspection GoStructTag

type ExitCmd

type ExitCmd struct {
	Cmd struct{} `"exit"` //nolint
}

noinspection GoStructTag

type FailTimeParams

type FailTimeParams struct {
	Dummy        struct{} `"ft"`          //nolint
	FailDuration float64  `(@Int|@Float)` //nolint
	FailInterval float64  `(@Int|@Float)` //nolint
}

noinspection GoStructTag

type FieldHeight

type FieldHeight struct {
	Val int `"fh" @Int` //nolint
}

noinspection GoStructTag

type FieldWidth

type FieldWidth struct {
	Val int `"fw" @Int` //nolint
}

noinspection GoStructTag

type FullScreen

type FullScreen struct {
	FullScreen struct{} `"fs"` //nolint
}

noinspection GoStructTag

type GoCmd

type GoCmd struct {
	Cmd     struct{}  `"go"`                      //nolint
	Seconds float64   `( (@Int|@Float)`           //nolint
	Ever    *EverFlag `| @@ )`                    //nolint
	Speed   *float64  `[ "speed" (@Int|@Float) ]` //nolint
}

noinspection GoStructTag

type GuiFlag

type GuiFlag struct {
	Dummy struct{} `"gui"` //nolint
}

noinspection GoStructTag

type HopLimitFlag

type HopLimitFlag struct {
	Val int `("hoplimit" | "hl") @Int` //nolint
}

noinspection GoStructTag

type IntervalFlag

type IntervalFlag struct {
	Val int `("interval"|"itv") @Int` //nolint
}

noinspection GoStructTag

type Ipv6Address

type Ipv6Address struct {
	Addr string `@String` //nolint
}

noinspection GoStructTag

type JoinsCmd

type JoinsCmd struct {
	Cmd struct{} `"joins"` //nolint
}

noinspection GoStructTag

type MaxSpeedFlag

type MaxSpeedFlag struct {
	Dummy struct{} `( "max" | "inf")` //nolint
}

noinspection MaxSpeedFlag

type Move

type Move struct {
	Cmd    struct{}     `"move"` //nolint
	Target NodeSelector `@@`     //nolint
	X      int          `@Int`   //nolint
	Y      int          `@Int`   //nolint
}

noinspection GoStructTag

type NetInfoCmd

type NetInfoCmd struct {
	Cmd     struct{}     `"netinfo" (`         //nolint
	Version *string      `  "version" @String` //nolint
	Commit  *string      `| "commit" @String`  //nolint
	Real    *YesOrNoFlag `| "real" @@ )+`      //nolint
}

noinspection GoStructTag

type NoFlag

type NoFlag struct {
	Dummy struct{} `("n"|"no"|"false"|"0")` //nolint
}

noinspection GoStructTag

type NodeCmd

type NodeCmd struct {
	Cmd     struct{}     `"node"`      //nolint
	Node    NodeSelector `@@`          //nolint
	Command *string      `[ @String ]` //nolint
}

noinspection GoStructTag

type NodeSelector

type NodeSelector struct {
	Id int `@Int` //nolint
}

noinspection GoStructTag

func (*NodeSelector) String

func (ns *NodeSelector) String() string

type NodeType

type NodeType struct {
	Val string `@("router"|"fed"|"med"|"sed")` //nolint
}

noinspection GoStructTag

type NodesCmd

type NodesCmd struct {
	Cmd struct{} `"nodes"` //nolint
}

noinspection GoStructTag

type NoneFlag

type NoneFlag struct {
	Dummy struct{} `"none"` //nolint
}

noinspection GoStructTag

type OffFlag

type OffFlag struct {
	Dummy struct{} `"off"` //nolint
}

noinspection GoStructTag

type OnFlag

type OnFlag struct {
	Dummy struct{} `"on"` //nolint
}

noinspection GoStructTag

type OnOrOffFlag

type OnOrOffFlag struct {
	On  *OnFlag  `( @@`   //nolint
	Off *OffFlag `| @@ )` //nolint
}

noinspection GoStructTag

type PartitionsCmd

type PartitionsCmd struct {
	Cmd struct{} `( "partitions" | "pts")` //nolint
}

noinspection GoStructTag

type PingCmd

type PingCmd struct {
	Cmd      struct{}      `"ping"`   //nolint
	Src      NodeSelector  `@@`       //nolint
	Dst      *NodeSelector `( @@`     //nolint
	AddrType *AddrTypeFlag `  [ @@ ]` //nolint
	DstAddr  *Ipv6Address  `| @@)`    //nolint
	DataSize *DataSizeFlag `( @@`     //nolint
	Count    *CountFlag    `| @@`     //nolint
	Interval *IntervalFlag `| @@`     //nolint
	HopLimit *HopLimitFlag `| @@ )*`  //nolint
}

noinspection GoStructTag

type PingsCmd

type PingsCmd struct {
	Cmd struct{} `"pings"` //nolint
}

noinspection GoStructTag

type PlrCmd

type PlrCmd struct {
	Cmd struct{} `"plr"`             //nolint
	Val *float64 `[ (@Int|@Float) ]` //nolint
}

noinspection GoStructTag

type RadioCmd

type RadioCmd struct {
	Cmd      struct{}        `"radio"` //nolint
	Nodes    []NodeSelector  `( @@ )+` //nolint
	On       *OnFlag         `( @@`    //nolint
	Off      *OffFlag        `| @@`    //nolint
	FailTime *FailTimeParams `| @@ )`  //nolint
}

noinspection GoStructTag

type RadioRange

type RadioRange struct {
	Val int `"rr" @Int` //nolint
}

noinspection GoStructTag

type RadioRangeFlag

type RadioRangeFlag struct {
	Val int `"rr" @Int` //nolint
}

noinspection GoStructTag

type RestoreFlag

type RestoreFlag struct {
	Dummy struct{} `"restore"` //nolint
}

noinspection GoStructTag

type ScanCmd

type ScanCmd struct {
	Cmd  struct{}     `"scan"` //nolint
	Node NodeSelector `@@`     // nolint
}

noinspection GoStructTag

type SpeedCmd

type SpeedCmd struct {
	Cmd   struct{}      `"speed"`               //nolint
	Max   *MaxSpeedFlag `( @@`                  //nolint
	Speed *float64      `| [ (@Int|@Float) ] )` //nolint
}

noinspection GoStructTag

type TitleCmd

type TitleCmd struct {
	Cmd      struct{} `"title"`              //nolint
	Title    string   `@String`              //nolint
	X        *int     `( "x" (@Int|@Float) ` //nolint
	Y        *int     `| "y" (@Int|@Float) ` //nolint
	FontSize *int     `| "fs" @Int )*`       //nolint
}

noinspection GoStructTag

type VisualizeArg

type VisualizeArg struct {
	Flag struct{}  `"v"`    //nolint
	None *NoneFlag `( @@`   //nolint
	Gui  *GuiFlag  `| @@ )` //nolint
}

noinspection GoStructTag

type WebCmd

type WebCmd struct {
	Cmd struct{} `"web"` //nolint
}

noinspection GoStructTag

type YesFlag

type YesFlag struct {
	Dummy struct{} `("y"|"yes"|"true"|"1")` //nolint
}

noinspection GoStructTag

type YesOrNoFlag

type YesOrNoFlag struct {
	Yes *YesFlag `( @@`   //nolint
	No  *NoFlag  `| @@ )` //nolint
}

noinspection GoStructTag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL