| 1 |
This is a 2009/wk14 version of NoTA L_IN release 3. |
| 2 |
|
| 3 |
Tested with Ubuntu releases 8.10. |
| 4 |
|
| 5 |
L_IN |
| 6 |
==== |
| 7 |
|
| 8 |
L_IN is lower level entity for NoTA DIP providing connection logistics and data transport layers for the stack. |
| 9 |
It has a configuration file l_in_up.h in l_in_up directory.This file contains entities used by l_in_up viz |
| 10 |
l_in socket_count, timeout and also manages environment variables for Manager and Gateway.It can be configured |
| 11 |
suitable to individual needs within the limits of NoTA. |
| 12 |
|
| 13 |
|
| 14 |
Instructions for building L_IN |
| 15 |
============================== |
| 16 |
|
| 17 |
./configure |
| 18 |
make clean all |
| 19 |
|
| 20 |
|
| 21 |
The l_in library can be used with pkg-config or directly linking to the |
| 22 |
library files. |
| 23 |
|
| 24 |
|
| 25 |
LManager |
| 26 |
======== |
| 27 |
|
| 28 |
When running l_ins, there needs to be LManager. Information who is LManager |
| 29 |
is given with environment variable NOTA_LMANAGER. This is important specially |
| 30 |
when running with singleprocess H_IN stack. |
| 31 |
|
| 32 |
example |
| 33 |
------- |
| 34 |
NOTA_LMANAGER=1 ./your_application_sp your_application_params |
| 35 |
NOTA_LMANAGER=1 notaworld_svn/h_in/test/.libs/simple_tester_sn_sp |
| 36 |
|
| 37 |
|
| 38 |
Transports |
| 39 |
========== |
| 40 |
|
| 41 |
Configure takes the selected Ldown as parameter. It can be changed by running |
| 42 |
configure with parameter "--with-transports=" default value is tcp. |
| 43 |
|
| 44 |
example |
| 45 |
------- |
| 46 |
|
| 47 |
./configure --with-transport=tcp |
| 48 |
./configure --with-transport=fifo |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
Multiple reference L_IN_UPs |
| 54 |
=========================== |
| 55 |
|
| 56 |
Multiple L_IN ups can be enabled within same process. This means that all the |
| 57 |
calls to reference l_in_up's function l_in_get_instance() will create a new instance of the reference L_IN_UP. This enables running of multiple reference l_in_up within a single process. Further this meas that all l_in_up instances will load their l_downs separately, and so developer can run multiple instance of the same l_down within same process. |
| 58 |
|
| 59 |
|
| 60 |
example |
| 61 |
------- |
| 62 |
|
| 63 |
To run the singleprocess memory l_down with multiple reference cores. |
| 64 |
./configure --with-transports=single --enable-multi-reference-l_in_up |
| 65 |
|
| 66 |
To run the l_in_up with TCP l_down with the possibility to have the l_downs within same process. |
| 67 |
./configure --with-transports=tcp --enable-multi-reference-l_in_up |
| 68 |
|
| 69 |
|
| 70 |
With refrerence h_core |
| 71 |
---------------------- |
| 72 |
|
| 73 |
This one process feature can be further enlarged with enabling multiple h_cores within same process. All h_core instances will then load separate l_in_ups. |
| 74 |
|
| 75 |
h_in> ./configure --enable-multi-reference-h_in_core |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
TCP l down (ld_tcp) |
| 81 |
=================== |
| 82 |
|
| 83 |
TCP ldown by default uses broadcast and multicast, but if developing in same |
| 84 |
network, ther e is problems as two LManagers are existing. To avoid this also |
| 85 |
ldown_tcp is provided with static ip support. With static ip, we always point |
| 86 |
to LManagers IP address. If two tcp_ldowns are existing in same system, the |
| 87 |
Lmanager one needs to be started first. LManager uses static port 7100. |
| 88 |
|
| 89 |
To enable static ip one needs to have tcp transport enabled. |
| 90 |
|
| 91 |
|
| 92 |
examples |
| 93 |
-------- |
| 94 |
./configure --with-static_ip=127.0.0.1 |
| 95 |
Above example also is a special case where NoTA network contains only loopback as the transport. |
| 96 |
|
| 97 |
./configure --with-transports=tcp --with-static_ip=10.0.0.33 |
| 98 |
|
| 99 |
|
| 100 |
known problems |
| 101 |
-------------- |
| 102 |
LManager always needs to be started first. |
| 103 |
|
| 104 |
Occasianally tcp/ip server is left allocated, and Ldown isn't able to utilize |
| 105 |
same tcp server port. This problems fixes it self usually within a minute, as |
| 106 |
soon as the tcp server port 7100 is released by the system. |
| 107 |
|
| 108 |
There is no environment variable to change the static address, or to change |
| 109 |
the tcp server port. This feature is planned to be added there in future. |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
Instructions for using NOTA_TCP_IP_IF environment variable(wlan case especially) |
| 115 |
=============================================================================== |
| 116 |
|
| 117 |
TCP now provides NOTA_TCP_IP_IF env variable, which allows the option of using |
| 118 |
default(eth) interface or wlan interface depending on the transport used for |
| 119 |
communication.This is done to fetch the broadcast address from the local iptables. |
| 120 |
Default broadcast/multicast address in code doesn't work in case of wlan.If this |
| 121 |
env variable is not provided then communication happens with the broadcast/multicast |
| 122 |
provided in the code.It is advisable to have only one interface during communication. |
| 123 |
|
| 124 |
|
| 125 |
Eg. |
| 126 |
|
| 127 |
CASE 1: (without NOTA_TCP_IP_IF environment variable) |
| 128 |
======= |
| 129 |
Run SN as: |
| 130 |
NOTA_LMANAGER=1 ./simple_tester_sn_sp |
| 131 |
|
| 132 |
Run AN as: |
| 133 |
./simple_tester_an_sp |
| 134 |
|
| 135 |
|
| 136 |
CASE 2: (with NOTA_TCP_IP_IF environment variable and using ethernet interface) |
| 137 |
======= |
| 138 |
Run SN as: |
| 139 |
NOTA_TCP_IP_IF=eth0 NOTA_LMANAGER=1 ./simple_tester_sn_sp |
| 140 |
|
| 141 |
Run AN as: |
| 142 |
NOTA_TCP_IP_IF=eth0 ./simple_tester_an_sp |
| 143 |
|
| 144 |
|
| 145 |
CASE 3: (with NOTA_TCP_IP_IF environment variable and using wlan interface) |
| 146 |
======= |
| 147 |
Run SN as: |
| 148 |
NOTA_TCP_IP_IF=wlan0 NOTA_LMANAGER=1 ./simple_tester_sn_sp |
| 149 |
|
| 150 |
Run AN as: |
| 151 |
NOTA_TCP_IP_IF=wlan0 ./simple_tester_an_sp |
| 152 |
|
| 153 |
|
| 154 |
With daemon version there is no need to run with NOTA_TCP_IP_IF |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
Single process l_down (ld_single) |
| 159 |
================================= |
| 160 |
|
| 161 |
Single process l_down is designed to be run withing single process. It is |
| 162 |
able to provide l_down interface between multiple l_in_ups. Reasoning for |
| 163 |
this l_down is that multiple h_in and l_in_up stacks can be run within same |
| 164 |
process for testing and developing purpoces. |
| 165 |
|
| 166 |
example |
| 167 |
------- |
| 168 |
|
| 169 |
To enable single process for l_in |
| 170 |
|
| 171 |
./configure --with-transports=single |
| 172 |
|
| 173 |
To enable multiple reference l_in_ups with single process ldown |
| 174 |
|
| 175 |
./configure --with-transports=single --enable-multi-reference-l_in_up |
| 176 |
|
| 177 |
And also enable multiple reference h_cores |
| 178 |
|
| 179 |
h_in> ./configure --enable-multi-reference-h_in_core |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
USB l down (ld_usb) |
| 184 |
=================== |
| 185 |
|
| 186 |
LdUSB provides USB adaptation for the NoTA devices. The code has been made and tested with Ubuntu/Linux laptop and N810. Laptop in host mode and N810 either in host or device mode. The mode is automatically checked, when ld_usb is started. |
| 187 |
|
| 188 |
There are two versions of host side adaptation available: libusb v.0.1 and libusb v.1.0. (Libusb v1.0 is in file ld_usb_host_libusb_v1_0.c and must be manually taken into build). |
| 189 |
|
| 190 |
Device side (N810) adaptation is made using gadgetfs. |
| 191 |
|
| 192 |
Usage |
| 193 |
----- |
| 194 |
|
| 195 |
1. Connect laptop and N810 with a usb cable. |
| 196 |
2. Mount gadgetfs in N810 as root: |
| 197 |
# sudo gainroot |
| 198 |
# insmod /mnt/initfs/lib/modules/2.6.21-omap1/gadgetfs.ko |
| 199 |
# mkdir /dev/gadget |
| 200 |
# mount -t gadgetfs gadgetfs /dev/gadget (try again when first try fails) |
| 201 |
# mount -t gadgetfs gadgetfs /dev/gadget |
| 202 |
3. Start ld_usb (i.e. NoTA application) in N810 as root |
| 203 |
4. Start ld_usb (i.e. NoTA application)in laptop as root |
| 204 |
|
| 205 |
Known problems |
| 206 |
-------------- |
| 207 |
|
| 208 |
The performance is poor. (This is due unreliable send in gadgetfs and resends. Better user-space interface is needed.) |
| 209 |
|
| 210 |
Both N810 and laptop side must have sufficient permissions to access USB devices. At default, Linux gives only root users access to new devices. Easiest alternative is to execute code with root privileges. If this is unsuitable, additional configuration is needed (see e.g. www.gphoto.org/doc/manual/permissions-usb.html for example). |
| 211 |
|
| 212 |
Libusb v1.0 does not support hotplugging. New NoTA usb devices are discovered only when ld_usb is started. If devices are connected later on they are not detected. Support for hotplugging has been promised for libusb v1.1. |
| 213 |
|
| 214 |
Device-side initialization (gadgetfs configuration) fails if USB cable is not plugged and connected to USB host. |
| 215 |
|
| 216 |
The solution does not configure automatically to every USB hardware/driver. |
| 217 |
- Maximum LdUSB packet size is 512 bytes. In slow USB connections (older than v2.0) this will cause problems. The packet size should be adapted dynamically. |
| 218 |
- Some drivers in device-side (gadgetfs) may require different configuration |
| 219 |
|
| 220 |
USB devices are recognized to be NoTA compatible using the following vendor and product ID's 0x0000, 0x0123. These are just for the laboratory tests. In real world they may cause clashes with other products. |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
Branch coverage |
| 225 |
=============== |
| 226 |
|
| 227 |
Branch coverage is used to determine which parts of the code gets run. L_IN in default uses |
| 228 |
'gcov' coverage package included in gcc compiler collection. "--enable-coverage" parameter |
| 229 |
in ./configure scripts enables value "-g -O0 -ftest-coverage -fprofile-arcs -static" is set to |
| 230 |
CFLAGS variable. This generates branching functionalities in compiled code as well as it enables |
| 231 |
linking to gcov library, to enable runtime support of coverage features. To be able to do |
| 232 |
branch coverage in libraries static linking needs to be enabled. |
| 233 |
|
| 234 |
enabling and building |
| 235 |
--------------------- |
| 236 |
|
| 237 |
Coverage is enabled with --enable-coverage flag to configure script. It is recommended |
| 238 |
that possible old files are cleaned with command 'make clean_coverage'. Command 'make clean all' |
| 239 |
cleans binary files and forces coverage support files to be generated. |
| 240 |
|
| 241 |
l_in$ ./configure --enable-coverage |
| 242 |
l_in$ make clean_coverage clean all |
| 243 |
|
| 244 |
After the branch coverage configurations have been done, desired softwares can be run from where the |
| 245 |
h_in branch coverage is aimed to study. |
| 246 |
|
| 247 |
|
| 248 |
gcov results |
| 249 |
------------ |
| 250 |
|
| 251 |
There is a script file to help getting results of coverage run. It requires a directory where to |
| 252 |
store the results as a parameter. The rest of the parameters will be passed to the actual |
| 253 |
gcov call as parameters. |
| 254 |
|
| 255 |
l_in$ ./coverage.sh gcov_result |
| 256 |
|
| 257 |
or for more detail |
| 258 |
|
| 259 |
l_in$ ./coverage.sh gcov_result -b |
| 260 |
|
| 261 |
|
| 262 |
lcov results (in HTML format) |
| 263 |
----------------------------- |
| 264 |
|
| 265 |
lcov_coverage.sh script file helps getting results of coverage run in HTML format. It requires a |
| 266 |
directory where to store the results as a parameter. |
| 267 |
|
| 268 |
l_in$ ./lcov_coverage.sh lcov_result |