Commit 5d752ccf authored by Federico Sismondi's avatar Federico Sismondi

code clean up, doc update

parent b7ccc4ca
Agent for the f-interop platform
--------------------------------
Agent for the f-interop platform (ioppytest-agent)
--------------------------------------------------
Design
------
......@@ -12,7 +12,6 @@ Note well
----
Agent is only supported by python2 -> tun librarires py2 only
Core
----
When started, the agent starts up the core module. This component is in
......@@ -179,8 +178,8 @@ tunneling all traffic through AMQP messages.
For running the agent you will need privileges on the machine, basically
cause we need to open a virtual interface to tunnel the packets.
The command for executing it will be provided to you by F-Interop web
GUI,it should look something like this:
The command for executing it will be provided to you by the
GUI or AMQP broker sys admin, it should look something like this:
```
sudo python -m agent connect --url amqp://someUser:somePassword@f-interop.rennes.inria.fr/sessionXX --name coap_client
......
......@@ -2,29 +2,26 @@
"""
Agent for f-interop
*******************
ioppytest-agent CLI:
********************
Installation
------------
The installation for the user is supposed to be as simple as possible. Ideally, the user
should only have the ./finterop tool installed with the relevant dependencies and should
be ready to go.
TBD
Features of the agent
----------------------
* The agent must be able to inject packets in the local loop or re-emit packets it receives
from the f-interop backend.
from the testing tool.
* The agent MUST be able to authenticate itself with the backend.
* The agent will monitor all the network traffic passing through it and send it to the backend.
* The agent isn't the way the user interact with test. It simply connects to f-interop and from there receive
instruction. All the commands send from the agent are for debugging and developing purposes and won't be enabled
by default in the final version.
* The agent isn't the way the user interact with test coordinator/manager. It simply connects to backend to establish a
sort of virtual network.
"""
import logging
import click
......@@ -44,9 +41,7 @@ try:
except ImportError:
from urlparse import urlparse
__version__ = (0, 1, 0)
DEFAULT_PLATFORM = 'f-interop.paris.inria.fr'
DEFAULT_PLATFORM = 'f-interop.rennes.inria.fr'
LOGGER = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
......@@ -84,7 +79,7 @@ command:
expected result:
agent is connected to f-interop and now awaits bootstrap command from backend
agent is listening to event bus and now awaits bootstrap command
---------------------------------------------------------------------
......@@ -101,7 +96,7 @@ command:
--ipv6-host 100
expected result:
agent is connected to f-interop, bootstrapped, and has an assigned
agent is listening to event bus, bootstrapped, and has an assigned
IPv6 (check interface with ifconfig)
---------------------------------------------------------------------
......@@ -123,7 +118,7 @@ command:
expected result:
agent is connected to f-interop, bootstrapped, agent plays the role of a router, and hence forwards packets
agent is listening to event bus, bootstrapped, agent plays the role of a router, and hence forwards packets
from bbbb:: network to cccc:: network, devices in the cccc:: network should be able to ping6 devices in the
bbbb:: network and vice-versa.
......@@ -137,7 +132,7 @@ TODO document --router-mode for re-routing the packets to another interface
\b
---------------------------------------------------------------------
For exploring all "connect" command option type: python -m agent connect --help
For more information visit: http://doc.f-interop.eu
For more information: README.md
---------------------------------------------------------------------
"""
......@@ -155,7 +150,7 @@ For more information visit: http://doc.f-interop.eu
param_decls=["--url"],
default="amqp://guest:guest@localhost/",
required=True,
help="AMQP url provided by F-Interop")
help="AMQP url of the session")
self.session_amqp_exchange = click.Option(
param_decls=["--exchange"],
......@@ -226,7 +221,7 @@ For more information visit: http://doc.f-interop.eu
def handle_connect(self, url, exchange, name, dump, force_bootstrap, ipv6_host, ipv6_prefix, serial):
"""
Authenticate USER and create agent connection to f-interop.
Authenticate USER and create agent connection to AMQP broker.
"""
......
"""
Plugin to connect to the F-interop backend
Plugin to connect to the AMQP broker
"""
import json
import logging
......
......@@ -154,11 +154,11 @@ class TunConsumer(BaseConsumer):
self.log.debug(("Data", message.data))
self.log.debug('\n* * * * * * * * * * * * * * * * * * * * * * *')
self.log.info("Message received from F-Interop. Injecting in Tun. Message count (downlink): %s"
self.log.info("Message received from testing tool. Injecting in Tun. Message count (downlink): %s"
% self.packet_count)
self.tun._eventBusToTun(
sender="F-Interop server",
sender="Testing Tool",
signal="tun inject",
data=message.data
)
......
......@@ -6,53 +6,6 @@ import pytest
log = logging.getLogger(__name__)
"""
primer from 6p openwsn-fw/build/OpenMote-CC2538_armgcc/openstack/02b-MAChigh/sixtop.h
//=========================== define ==========================================
// 6P version
#define IANA_6TOP_6P_VERSION 0x01
// 6P command Id
#define IANA_6TOP_CMD_NONE 0x00
#define IANA_6TOP_CMD_ADD 0x01 // CMD_ADD | add one or more cells
#define IANA_6TOP_CMD_DELETE 0x02 // CMD_DELETE | delete one or more cells
#define IANA_6TOP_CMD_COUNT 0x03 // CMD_COUNT | count scheduled cells
#define IANA_6TOP_CMD_LIST 0x04 // CMD_LIST | list the scheduled cells
#define IANA_6TOP_CMD_CLEAR 0x05 // CMD_CLEAR | clear all cells
// 6P return code
#define IANA_6TOP_RC_SUCCESS 0x06 // RC_SUCCESS | operation succeeded
#define IANA_6TOP_RC_VER_ERR 0x07 // RC_VER_ERR | unsupported 6P version
#define IANA_6TOP_RC_SFID_ERR 0x08 // RC_SFID_ERR | unsupported SFID
#define IANA_6TOP_RC_BUSY 0x09 // RC_BUSY | handling previous request
#define IANA_6TOP_RC_RESET 0x0a // RC_RESET | abort 6P transaction
#define IANA_6TOP_RC_ERR 0x0b // RC_ERR | operation failed
// states of the sixtop-to-sixtop state machine
typedef enum {
// ready for next event
SIX_IDLE = 0x00,
// sending
SIX_SENDING_REQUEST = 0x01,
// waiting for SendDone confirmation
SIX_WAIT_ADDREQUEST_SENDDONE = 0x02,
SIX_WAIT_DELETEREQUEST_SENDDONE = 0x03,
SIX_WAIT_COUNTREQUEST_SENDDONE = 0x04,
SIX_WAIT_LISTREQUEST_SENDDONE = 0x05,
SIX_WAIT_CLEARREQUEST_SENDDONE = 0x06,
// waiting for response from the neighbor
SIX_WAIT_ADDRESPONSE = 0x07,
SIX_WAIT_DELETERESPONSE = 0x08,
SIX_WAIT_COUNTRESPONSE = 0x09,
SIX_WAIT_LISTRESPONSE = 0x0a,
SIX_WAIT_CLEARRESPONSE = 0x0b,
// response senddone
SIX_REQUEST_RECEIVED = 0x0c,
SIX_WAIT_RESPONSE_SENDDONE = 0x0d
} six2six_state_t;
"""
try:
AMQP_URL = str(os.environ['AMQP_URL'])
AMQP_EXCHANGE = str(os.environ['AMQP_EXCHANGE'])
......@@ -122,256 +75,6 @@ def test_zmq(producer):
body=json.dumps(d))
def test_6p_add(producer):
"""
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pAdd", "[6,7]"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_6p_count(producer):
"""
TODO: Write docs
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pCount", "0"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_6p_list(producer):
"""
TODO: Write docs
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pList", "0"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_6p_clear(producer):
"""
TODO: Write docs
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pClear", "0"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_6p_delete(producer):
"""
TODO: Write docs
Use 3 arguments
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pDelete", "[6,7]"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_6p_answers(producer):
"""
enable/disable 6P response (set value to 1 to enable, 0 to disable)
Test if 6P answers can be enable/disabled to create timeouts.
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "6pResponse", "1"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_send_dio(producer):
"""
Used in 6TiSCH testing.
set the period at the which the device sends DIOs (value in milli-seconds)
TODO: Implemented by which nodes? DAG ? 6N ?
Returns:
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "dioPeriod", "1000"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_send_dao(producer):
"""
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
set the period at the which the device sends DAOs (value in milli-seconds)
Returns:
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "daoPeriod", "1000"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
body=json.dumps(d))
def test_send_keep_alive(producer):
"""
TODO: Implemented by which nodes? DAG ? 6N ?
Used in 6TiSCH testing.
set the timeout which the device send a keepAlive(value in slots)
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "kaPeriod", "1000"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
body=json.dumps(d))
def test_channel(producer):
"""
set the communication channel
TODO: Implemented by which nodes? DAG ? 6N ?
Used in 6TiSCH testing.
Returns:
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "channel", "6"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_control_ebperiod(producer):
"""
set the period at the which the device sends enhanced beacons (value in seconds)
Used in 6TiSCH testing.
TODO: Implemented by which nodes? DAG ? 6N ?
Returns:
"""
d = {"zmq_socket_type": "req",
"url": "tcp://localhost:60000",
"payload": {"signal": "cmdToMote",
"data": {
"action": ["imageCommand", "ebPeriod", "2"],
"serialPort": "/dev/ttyUSB0"
},
"sender": "f-interop agent"}}
producer.basic_publish(exchange=AMQP_EXCHANGE,
routing_key='control.zeromq.req.client',
mandatory=True,
body=json.dumps(d))
def test_control_tun_start(producer):
"""
Starts tun interface in agent 1 and agent 2
......
......@@ -507,7 +507,7 @@ class OpenTunLinux(object):
log.debug("Pushing message to topic: %s" % routing_key)
self.packet_count += 1
log.info("Messaged captured in tun. Pushing message to F-Interop. Message count (uplink): %s"
log.info("Messaged captured in tun. Pushing message to testing tool. Message count (uplink): %s"
% self.packet_count)
# dispatch to EventBus
......@@ -722,7 +722,7 @@ class OpenTunMACOS(object):
log.debug("Pushing message to topic: %s" % routing_key)
self.packet_count += 1
log.info("Messaged captured in tun. Pushing message to F-Interop. Message count (uplink): %s"
log.info("Messaged captured in tun. Pushing message to testing tool. Message count (uplink): %s"
% self.packet_count)
# dispatch to EventBus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment