Network SEQuence Executor
NSEQE is a library that allow users to create a sequence of messages exchange between hosts.
A node represents a host on the network. It is defined by:
- a list of
tasks, which run in the background - a
sequence, which defines the ordered actions the node will perform
node:
tasks: []
sequence:Tasks are asynchronous, periodic actions that persist throughout the application's lifetime.
They are executed in parallel with the sequence.
Each entry in a node's sequence is called an action, defined by the required "action" key.
The fields associated with an action vary depending on its type.
Each action must specify a protocol. The supported protocols currently are tcp and udp.
The supported actions are
connect– establish a connection to a remote hostdisconnect– close a connection to a remote hostbind– create a TCP server socketsend– send a message (unicast or broadcast)wait– wait for an event to occursleep– block the sequence for a given duration
The connect action makes a socket connection to a remote host (or node).
action: connect
to:
addr: 192.168.1.5
port: 8000
timeout_ms: 5000The disconnect action disconnect the node from a remote host if a connection between the two exists.
action: disconnect
target:
addr: 192.168.1.5
port: 8000The bind action creates a TCP server on the given address and port.
action: bind
interface:
addr: 192.168.1.4
port: 8000
protocol: tcpSends a message either to specific remote hosts (unicast) or to a whole subnet (broadcast).
ℹ️ If the mode is
unicast, an active connection (seeconnect) is required.
action: send
mode: unicast
protocol: tcp
from:
addr: 192.168.0.1
to:
- addr: 192.168.0.6
port: 6900
buffer: [0x1, 0x1, 0x1]action: send
mode: broadcast
from:
addr: 192.168.0.1
to:
subnet: 192.168.0.0/24
buffer: [0x1, 0x1, 0x1]
The sleep event waits for a given amount of time before executing the next action.
action: sleep
duration_ms: 5000Blocks the sequence until a specified event occurs. Running tasks are not paused.
Supported events are :
sleep: pause for a durationmessages: wait for specific incoming messagesconnection: wait for a remote client to connect
Waits for one or more remote clients to connect to the local server.
action: wait
event: connection
protocol: tcp
connections:
- from:
addr: 192.168.1.2
to:
addr: 192.168.1.4
port: 3000
Waits for a list of incoming messages, optionally in a defined order.
unordered: proceed when all messages are received, in any order.ordered: messages must arrive in the defined order; otherwise, the sequence is blocked until the timeout.
action: wait
event: messages
timeout: 5000
messages:
order: unordered
list:
- from:
addr: 192.168.0.6
port: 6900
to:
addr: 192.168.0.1
port: 6901
protocol: udp
buffer: [0x1, 0x1, 0x1]
expect_response: falseenum Action {
Connect { to: Endpoint, timeout_ms: u64 },
Disconnect { target: Endpoint },
Bind { interface: Endpoint, protocol: Protocol },
Send { mode: SendMode, from: Address, to: Vec<Endpoint>, buffer: Vec<u8> },
Sleep { duration_ms: u64 },
Wait { event: WaitEvent },
}
enum WaitEvent {
Connection(Vec<ConnectionSpec>),
Messages { order: OrderType, list: Vec<MessageMatch>, timeout_ms: Option<u64> }This example create a server on a local IP address and port. Once the client connects, the node sends a message to it.
node:
tasks: []
sequence:
- action: bind
interface:
addr: 192.168.1.4
port: 8000
protocol: tcp
- action: wait
event: connection
connections:
- from:
addr: 192.168.1.3
to:
addr: 192.168.1.4
port: 8000
protocol: tcp
- action: send
mode: unicast
from:
addr: 192.168.1.4
to:
- addr: 192.168.1.3
port: 9999
protocol: udp
buffer: [0x1, 0x1, 0x1]