The Linux OS provides the GigE-V Framework with access to the standard network stack, suitable for grabbing single images, and also provides a high performance network packet access mechanism, suitable for streaming image sequences, that is traditionally used by packet sniffer applications.
To avoid packet loss on the network interface, a number of parameters may be adjusted by the user. Important parameters to maximize are the MTU (maximum transmission unit) size and the number of receive buffers available to the NIC driver. This helps reduce the number of packets to process and therefore minimizes CPU overhead and interrupts.
A network tuning script provided with the API can maximize the MTU (enabling Jumbo frames) and optimize certain network settings, including the number of receive buffers, using a standard tool named “ethtool”. The gev_nettweak tuning script is located in the following directory:
$HOME/DALSA/GigeV/bin/
For example, to adjust network interface eth0, use the following terminal command to run the script (administrator privileges are required):
sudo ./gev_nettweak eth0

The “gev_nettweak” script adjusts the following parameters to assist the standard network stack in buffering more image data:
|
Parameter |
Description |
|
MTU |
Maximizes
the MTU (Maximal Tranmission Unit) size on the NIC. This corresponds to the
maximum packet size for image data. The use of NIC hardware whose drivers
support “Jumbo frames” aids in making this value as large as possible (
typically maximum is around 9K bytes (9216 bytes). |
|
net.ipv4.udp_rmem_min |
Adjust
the receive memory allocation size in the network stack. |
|
net.core.netdev_max_backlog |
Adjust the network packet backlog queue
size. |
|
net.unix.max_dgram_qlen |
Adjust the network queue length for UDP packets. Computes the amount of memory for UDP packets - a maximum image size and the number of cameras expected provide a hint for this setting. |
|
net.core.rmem_default net.core.rmem_max |
Adjust the default (and maximum) memory for receiving network packets. |
|
rx_value rx_jumbo |
Use "ethtool" utility (if present) to adjust the setting of the network device drivers to optimize the rx_ring and the rx jumbo packet queue for maximum throughput and to disable the rx pause operation. This improves reception of image data packets from the cameras. (Sending to the camera is not as critical) |
Access to the high performance packet access interface, mentioned above, is provided by the PF_PACKET socket interface and is restricted to processes that have a capability set that allows CAP_NET_RAW (permits raw access to an interface for capturing directly). Generally, this is accomplished either by using root / sudo permissions to run the program or to have the CAP_NET_RAW capability set up with the setcap utility that comes with the libcap library.
The ability to tune threads with specific CPU affinity values and higher priority is restricted to processes that have the capability set that allow CAP_SYS_NICE. Generally, this is accomplished either by using root / sudo permissions to run the program or to have the CAP_SYS_NICE capability set up with the setcap utility that comes with the libcap library. The CAP_SYS_NICE capability also allows the default scheduler (aka SCHED_OTHER) to be replaces with one of the real-time schedulers (SCHED_RR or SCHED_FIFO) for better thread handling performance.
|
|
Note: Some security environments can assign capabilities to executables with a configuration file (for example, /etc/permissions.local). |
Without the CAP_NET_RAW bit set, the library defaults to standard packet accesses using sockets reading UDP (User Datagram Protocol) packets from the network stack. While the standard network socket access works for receiving images from a camera, there can be considerable latency in frame reception as the data makes its way through the network stack. For minimal latency and higher data rates, it is recommended that the PF_PACKET interface be used by enabling the CAP_NET_RAW capability bit.
|
|
Note: The setcap utility usage is “setcap cap_net_raw+eip <application>”. Where <application> is the file name of the executables being used. This includes the application program and all the loadable libraries it uses, referenced from ldconfig instead of LD_LIBRARY_PATH. |
|
|
Note: When using “sudo” to provide the necessary permissions for the higher performance interface, remember to use “sudo –E” or “sudo –i” to invoke an interactive (login) shell in order to pick up the environment variables that point to the GenICam SDK installation. These are used at runtime to be able to set up and use the GenICam XML based features. |
Related Topics