-
Notifications
You must be signed in to change notification settings - Fork 10
Network layer. Compile and run example
Go to the directory with checked out evins and run:
make
In the example below is assumed, that you have two 2 EvoLogics modems with IP addresses 192.168.0.178 and 192.168.0.179. Each of the modems has 3 opened ports 9200, 9201 and 9202 (one port for one network protocol).
Configured network protocols:
- 9200 - flooding routing protocol (sncfloodr)
- 9201 - static routing protocol (staticr)
- 9202 - information carrying routing protocol (icrpr)
Before start configuring EviNS, please check the modems have opened ports 9200, 9201 and 9202. To do that connect to the modems, see example below:
> nc 192.168.0.178 9200
AT?ZSL
0 tcp://0.0.0.0:9200:lr|net -l "\n" -c 1 -x 1
1 tcp://0.0.0.0:9201:lr|net -p 1 -l "\n"
2 tcp://0.0.0.0:9202:lr|net -p 2 -l "\n"
> nc 192.168.0.179 9200
AT?ZSL
0 tcp://0.0.0.0:9200:lr|net -l "\n" -c 1 -x 1
1 tcp://0.0.0.0:9201:lr|net -p 1 -l "\n"
2 tcp://0.0.0.0:9202:lr|net -p 2 -l "\n"
More details about port configuration you can find in S2C Reference Manual (Interface configuration: the Interface String, p.17)
Create configuration file /usr/local/etc/fsm.conf or evins/etc/fsm.conf:
{module, alh1, [{role,at,iface,{socket,"192.168.0.178",9200,client}},
{role,at_impl,iface,{socket,"127.0.0.1",1101,server}},
{mfa,mod_mac,run,[{mac_protocol,csma_aloha}]}]}.
{module, nl1, [{role,at,iface,{socket,"127.0.0.1",1101,client}},
{role,nl_impl,iface,{socket,"0.0.0.0",1111,server}},
{mfa,mod_nl,run,[{nl_protocol,staticr}, {local_addr,1}, {routing,{2}},{neighbour_life, inf}]}]}.
Create configuration file /usr/local/etc/fsm.conf or evins/etc/fsm.conf:
{module, alh1, [{role,at,iface,{socket,"192.168.0.178",9200,client}},
{role,at_impl,iface,{socket,"127.0.0.1",1101,server}},
{mfa,mod_mac,run,[{mac_protocol,csma_aloha}]}]}.
{module, nl1, [{role,at,iface,{socket,"127.0.0.1",1101,client}},
{role,nl_impl,iface,{socket,"0.0.0.0",1111,server}},
{mfa,mod_nl,run,[{nl_protocol,sncfloodr}, {local_addr,1}]}]}.
Mac layer is connected to the modem, port 9200 and is configured with csma_aloha protocol. On top of mac layer is running routing protocol flooding with configured address 1.
Create configuration file /usr/local/etc/fsm.conf:
{module, mux_nl1, [{role,nl_mux,iface,{socket,"0.0.0.0",10001,server}},
{role,nl,iface,{socket,"127.0.0.1",1111,client}},
{role,nl,iface,{socket,"127.0.0.1",1112,client}},
{mfa,mod_mux_nl,run,[ ]}]}.
{module, mux_nl2, [{role,nl_mux,iface,{socket,"0.0.0.0",10002,server}},
{role,nl,iface,{socket,"127.0.0.1",2111,client}},
{role,nl,iface,{socket,"127.0.0.1",2112,client}}
{mfa,mod_mux_nl,run,[ ]}]}.
{module, alh1, [{role,at,iface,{socket,"192.168.0.178",9200,client}},
{role,alh,iface,{socket,"127.0.0.1",1101,server}},
{mfa,mod_mac,run,[{mac_protocol,csma_aloha}]}]}.
{module, nl1, [{role,alh,iface,{socket,"127.0.0.1",1101,client}},
{role,nl_impl,iface,{socket,"127.0.0.1",1111,server}},
{mfa,mod_nl,run,[{nl_protocol,sncfloodr}, {local_addr,1}]}]}.
{module, poll1, [{role,alh,iface,{socket,"192.168.0.178",9201,client}},
{role,nl,iface,{socket,"127.0.0.1",1112,server}},
{role,nmea,iface,{socket,"127.0.0.1",9601,server}},
{mfa,mod_polling,run,[{nl_protocol,polling}]}]}.
{module, alh2, [{role,at,iface,{socket,"192.168.0.179",9200,client}},
{role,alh,iface,{socket,"127.0.0.1",2101,server}},
{mfa,mod_mac,run,[{mac_protocol,csma_aloha}]}]}.
{module, nl2, [{role,alh,iface,{socket,"127.0.0.1",2101,client}},
{role,nl,iface,{socket,"127.0.0.1",2111,server}},
{mfa,mod_nl,run,[{nl_protocol,sncfloodr}, {local_addr,2}]}]}.
{module, poll2, [{role,alh,iface,{socket,"192.168.0.179",9201,client}},
{role,nl,iface,{socket,"127.0.0.1",2112,server}},
{role,nmea,iface,{socket,"127.0.0.1",9602,server}},
{mfa,mod_polling,run,[{nl_protocol,polling}]}]}.
Modules mux_nl1 and mux_nl2 open ports 10001 and 10002. This ports are configured as network layer multiplexer. So the user has one port with network layer interface to work with all 2 configured routing protocols(sncfloodr and polling protocols). sncfloodr is flooding based and can be used for discovery procedure.
Go to the directory with checked out **evins** and run:
_rel/evins/bin/evins console
> nc localhost 10001
> nc localhost 10002
The discovery procedure is used to find the neighbours in the network. Using the neighbour information the routing table for static (polling) routing protocol will be updated and can be used for data transmission.
Using other protocols it is possible to transmit only short messages (< 64 bytes).
To run the discovery procedure you have to connect to the port 10001 and run NL,discovery command with its parameters.
Format: NL,start,discovery,<Discovery period>,<Discovery total time>
During discovery total time, the modem will try to discover neighbours / times.
In the example below we run the discovery procedure for 30 seconds. After 30 s of discovery time (30/10 – 3 times sending broadcast), you will get NL,routing asynchronous message. It means the end of discovery. During discovery time, the channel is busy and you cannot transmit messages.
> nc localhost 10001
NL,start,discovery,10,30
NL,discovery,ok
NL,routing,3->3,2->2,4->4
The discovery procedure can be stopped. F.e. if you started NL,discovery for very long time. See an example below:
> nc localhost 10001
NL,start,discovery,100,100
NL,discovery,ok
NL,stop,discovery
NL,discovery,ok
After you have run the NL,discovery command you can get the parameters you have used.
> nc localhost 10001
NL,get,discovery NL,discovery,10,30
The Network layer multiplexer has 2 routing protocols configured. To get the list of configured routing protocols run command:
> nc localhost 10001
NL,get,protocols
NL,confprotocols,polling,sncfloodr
Set a routing protocol used currently for data transmission
> nc localhost 10001
Try to transmit data, but there is no routing protocol specified
<source>
NL,send,4,2,data
NL,error,noprotocol
NL,set,protocol,polling
NL,protocol,polling
Try to transmit data, but static protocol has no routing information for destination node 2
NL,send,4,2,data NL,error,norouting
Run discovery procedure to update the routing table for static routing
NL,start,discovery,10,30 NL,discovery,ok NL,routing,2->2
> nc localhost 10001
NL,send,70,2,0123456789012345678901234567890123456789012345678901234567890123456789
NL,send,0
> nc localhost 10002
NL,recv,70,1,2,0123456789012345678901234567890123456789012345678901234567890123456789