Nanomsg
The nanomsg node-type uses libnanomsg to exchange messages.
It is similar to the zeromq node-type.
nanomsg is a socket library that provides several common communication patterns. It aims to make the networking layer fast, scalable, and easy to use. Implemented in C, it works on a wide range of operating systems with no further dependencies.
The nanomsg node-type only implements the publish-subscribe protocol provided by nanomsg.
Prerequisites
This node-type requires libnanomsg (>= 1.0.0).
Implementation
The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/nanomsg.cpp
Configuration
Format Object (object) or Format Name (string) (format_spec) | |
string or Array of strings A single endpoint URI or list of URIs on which this node should listen for subscribers. | |
string or Array of strings A single endpoint URI or list of URIs pointing to which this node should connect to as a subscriber. | |
object (Output configuration (sent out by VILLASnode)) | |
object (Input configuration (received by VILLASnode)) | |
| vectorize | integer Default: 1 This setting allows to send multiple samples in a single message to the destination nodes. The value of this setting determines how many samples will be combined into one packet. |
Array of Hook Object (object) or Hook Name (string) (hook_list) | |
| builtin | boolean (Builtin hook functions) Default: true By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled. |
{- "format": "villas.human",
- "out": {
- "netem": {
- "enabled": true,
- "delay": 0,
- "jitter": 0,
- "distribution": "uniform",
- "loss": 0,
- "duplicate": 0,
- "corrupt": 0
}, - "vectorize": 0,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "in": {
- "signals": [
- {
- "name": "tap_position",
- "type": "integer",
- "init": 0
}, - {
- "name": "voltage",
- "type": "float",
- "unit": "V",
- "init": 230
}
], - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
], - "builtin": true
}Endpoints
The nanomsg supports several different transport mechanisms which are listed in the following table:
| Name | URI example | Documentation |
|---|---|---|
| In-process transport | inproc://test | nn_inproc(7) |
| Inter-process transport | ipc:///tmp/test.ipc | nn_ipc(7) |
| TCP transport | tcp://1.1.1.1:456 | nn_tcp(7) |
| WebSocket transport | ws://example.com:8080 | nn_ws(7) |
Example
nodes = {
nanomsg_node = {
type = "nanomsg"
out = {
endpoints = [
# TCP socket
"tcp://*:12000",
# Interprocess communication
"ipc:///tmp/test.ipc",
# Inprocess communication
"inproc://test"
]
}
in = {
endpoints = [
"tcp://127.0.0.1:12000",
"ipc:///tmp/test.ipc",
"inproc://test"
]
}
}
}