VNet User Guide
VNet User Guide
vNet
Network Virtualization Layer
for Arduino and Android
User Guide
VT-UxSI-01
Copyright (C) 2011 Veseo
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Printed in Italy
Veseo
Napoli
Revision Control
II
Index
1 Purpose and Intended Audience .......................................................................................................4
1.1 Download Source Code.............................................................................................................4
1.2 Base Code..................................................................................................................................4
1.3 Credits........................................................................................................................................4
2 Overview ..........................................................................................................................................5
2.1 Peer to Peer Network.................................................................................................................5
2.2 Supported Network Architectures..............................................................................................5
2.2.1 Single Media......................................................................................................................6
2.2.2 Bridged Networks..............................................................................................................6
2.2.3 Routed Network.................................................................................................................6
2.2.4 Bridged and Routed Networks...........................................................................................7
3 Network Configuration Rules............................................................................................................8
3.1 Addressing Rules.......................................................................................................................8
3.2 Address Translation....................................................................................................................9
3.3 Routing and Bridging Rules......................................................................................................9
4 Application Methods........................................................................................................................11
4.1 vNet Drivers.............................................................................................................................12
4.1.1 Ethernet TCP/IP W5100...................................................................................................12
4.1.2 Chibiduino - 2.4 GHz IEEE 802.15.4..............................................................................13
4.1.3 Future drivers...................................................................................................................13
5 vNet Configuration..........................................................................................................................14
5.1 Drivers Configuration..............................................................................................................15
6 vNet for Android (in progress)........................................................................................................17
7 Souliss Project Distributed Home Automation.............................................................................18
III
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
1.3 Credits
The vNet code is developed by Veseo and distributed as open source, you can use and
4/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
2 Overview
vNet is a network virtualization layer, that allow every application run over different
communication media without any change in the code. As additional feature, vNet
frames are routed and bridged automatically without any action on the application side,
creating a network of devices running over different communication medias, but
connected together.
vNet is developed for Arduino based platform, but the code can be easily ported over
different platforms. It support also Android based devices as node for the virtual
network.
The applications on the top of vNet can use server/client, master/slave or similar
concept.
5/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
In the simplest case, there are three nodes one for each type. Nodes first and second
type can exchange data via the third type, all nodes share the same application and the
vNet layer. One or more bridges are supported.
SuperNodes can identify automatically the routed path to reach the destination node or
may require definition of routing tables in case of more complex networks.
6/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
7/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
Furthermore, in vNet the addresses are split by media, this make easy identify which
media has to be used for the communication.
In the following table are shown the available ranges for all the media, the code support
up to five different media (not all are used up to now). A comparison of an address with
these ranges is used to find out the media of the relevant address.
Each media has an associated subnet mask, using a bit-wise AND between address and
subnet mask, is obtained the subnet of the device.
8/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
An address translation could create troubles, for example IPV4 routing will no longer
work, same for NAT. Is supported IP over the same subnet and VPNs.
Actually, only for IP based connection is required a translation because Chibiduino has
a two byte address.
Device within the same subnet must be in listening range, the concept of listening
range should be referred to the communication media that are used for the device. As
instance, for device that use wireless communication a listening range is the area where
the radio are able to send and receive message; for device that use a wired Ethernet a
listening range is the switched/routed IP network.
As per IPv4, frame that has a destination out of the own subnet are send to a device
with routing and/or bridging capability. In this case this device is called SuperNode
(and not Gateway) that will bridge or route the message.
A SuperNode address is typically the first available address for the subnet, so if you are
9/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
looking for the SuperNode of subnet subn you will send a message to subn &
0x0001. Additionally a routing table can be set to force preferred paths or not standard
addressing.
A device with two or more communication media is not automatically set as bridge, to
be a bridge require a SuperNode configuration. A SuperNode with two or mode
communication media, is able to bridge frames within its own media without any
additional configuration.
10/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
4 Application Methods
As described before, every application that use vNet can be used regardless the
communication media without any change in the code.
The following schematic shown the vNet structure, whatever is running on the
Application Layer can access one or more Media Interface through the vNet
Layer.
Application Layer
vNet Layer
The vNet Layer is not able to auto identify the available hardware, so an additional
configuration is required to enable the available media and define node behavior.
The main functions that are used in the Application Layer are the followings:
U8 vNet_DataAvailable();
U8 vNet_RetriveData(U8 *data);
The vNet_Send method send a message to a node identified with its address (addr), the
frame is automatically routed or bridged (if required).
11/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
The vNet_DataAvailable method looks for data available for any of the available
media, it will return the number of media that have at least one incoming message.
The vNet_RetriveData retrieve data from the buffer in order of media, should runs one
for each media that have at least one incoming message.
Other methods are available for setting up the address and routing/bridging rules for
complex architectures.
There is no longer the concept of server and client as in standard TCP/IP, each
device has a P2P connection build over two sockets.
Each device has one socket always in listening mode and one socket ready to open a
connection. When data has to be sent, the device start a connection on the listening
socket of the target, send data e close the connection. The target device, receive data on
the listening socket, if an answer is required it open a connection to the listening socket
of the device that targeted it.
12/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
So, the listening socket became a RX channel rather the other the TX one.
vNet frame structure and parsing functionality are quite similar to Chibiduino, so its a
natural extentions of this code. The previous release of vNet was released as
Chibiduino with routing, that basically extend the listening range using middle node
(SuperNode) that acts as a repeater.
vNet is basically the same, but allow more than one communication media, so act also
as a bridge. The availability of more media make it a virtualization layer.
13/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
5 vNet Configuration
The vNet configuration is performed with the file vNet_Config.h where the used can
set the main options.
//Vnet_Config.h
/**********************************************************/
/*!
If enabled allow broadcast support for incoming frames, to work properly
the same should be supported also by the communication media drivers.
Value SuperNode
0x0 Disable (Default)
0x1 Enable
*/
/**********************************************************/
#define VNET_BRDCAST 1
/**********************************************************/
/*!
A SuperNode is a device with routing and bridging capability, if Enable
message from Nodes of the own subnet can be sent out to other subnet.
Value SuperNode
0x0 Disable (Default)
0x1 Enable
*/
/**********************************************************/
#define VNET_SUPERNODE 0
/**********************************************************/
14/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
/*!
A Node or a Supernode can have one or more media interfaces active at
same time. A device (either Node or Supernode) automatically act as a
bridge between the active media.
Value Media
0x0 Disable (Default)
0x1 Enable
*/
/**********************************************************/
#define VNET_MEDIA1_ENABLE 0
#define VNET_MEDIA2_ENABLE 1
#define VNET_MEDIA3_ENABLE 0
#define VNET_MEDIA4_ENABLE 0
#define VNET_MEDIA5_ENABLE 0
15/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
16/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
The Android developers has a class with the same methods available for Arduino, any
Android device can act as a vNet node. Frames from Android devices can reach every
node of the vNet regardless the network architecture.
17/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
Souliss
Application
MaCaco Communication
Protocol
Memory Map
vNet Layer
There is no master/slave or server/client concept, each node can read or write data from
other nodes, a node can be either an Arduino or Android based devices. Data can be
18/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
pulled or pushed from and to a device, subcriptions and polling modes are available.
The Souliss application can have different modules to fit the requirements, as base an
Home Automation module is provided, this will implement logics and exchange data
using the base framework; an optional module for ID and Automatic Addressing can be
used for small plug and play networks.
The Souliss for Android is a bit different, because is thinked to be a graphical interface
for the user and has one communication media (WiFi).
Souliss
Application
Home DHCP
Automation
Scheduler and Skins
Scenarios
Network Plugin
Definition Device
SQLite
MaCaco Communication
Protocol
vNet Layer
Media Int.
1
19/20
Veseo
vNet User Guide
Doc. No.: VT-UxSI-01
20/20