Lost Ethernet Data Packets on Linux Systems

Last Revision Date: 7/5/2019

This article provides possible solutions to lost data packets when streaming images from a GigE Vision camera on Linux Ubuntu 16.04 or newer systems when using FlyCapture2 or Spinnaker API. 

CAUSE:

When streaming images from a GigE Vision camera on Linux Ubuntu 16.04 systems, a high number of lost data packets may be observed. In FlyCapture SDK applications, dropped packets result in IMAGE_CONSISTENCY_ERRORS returned; In Spinnaker SDK applications, dropped packets result in IMAGE_DATA_INCOMPLETE returned.

ANSWER:

To fix, try the following solutions:

1. INCREASE RECEIVE BUFFER SIZE

Increase the amount of memory Linux uses for receive buffers using the sysctl interface. In most Linux distributions, the system standard (default) and maximum values for this buffer default to 128 KB; increasing both of these parameters to 10 MB significantly improves image streaming results.

Note: You may need to increase the receive buffer size to greater than 10 MB if the streaming results are not satisfactory (For instance, for an Oryx 10GigE camera, 25 MB is recommended). Increasing the buffer size can enhance receive performance, but it also uses more memory.

To check the current receive buffer size (max and default), run the following commands:

$ cat /proc/sys/net/core/rmem_max

$ cat /proc/sys/net/core/rmem_default

To PERMANENTLY update the receive buffer size:
1. Run the following command:
$ sudo gedit /etc/sysctl.conf

Add the following lines to the bottom of the /etc/sysctl.conf file:

net.core.rmem_max=10485760
net.core.rmem_default=10485760

Once changes are persisted, they can be reloaded at any time by running the
following command in sysctl:
$ sudo sysctl -p

To TEMPORARILY update the receive buffer size until the next reboot, run the
following commands:
$ sudo sysctl -w net.core.rmem_max=10485760
$ sudo sysctl -w net.core.rmem_default=10485760

2. ENABLE JUMBO PACKET

Jumbo Packet is strongly recommended to be enabled for the network adapter and
the camera, in order to greatly improve streaming results.

2.1 Enable Jumbo Packet for the network adapter

Run ifconfig and find the network adapter that the cameras are connected to
(eg. enp15s0):

$ ifconfig

It might be necessary to disconnect the camera and run ifconfig again to find
the output difference, in order to find the network adapter name.

To PERMANENTLY enable Jumbo Packet for a specific network adapter, eg. enp15s0:

1. Open up /etc/network/interfaces in a text editor (as sudo):

$ sudo gedit /etc/network/interfaces

2. Add the following lines
(change enp15s0 to match the name of the adapter connected to the camera,
the address and netmask of the network adapter can also be configured here):

iface enp15s0 inet static
address 169.254.0.64
netmask 255.255.0.0
mtu 9000

auto enp15s0

3. Reboot the computer before using any GigE cameras.

To TEMPORARILY update enable Jumbo Packet until the next reboot, for a specific
network adapter, eg. enp15s0, run the following commands:
$ sudo ifconfig enp15s0 mtu 9000

2.2 Enable Jumbo Packet for the camera

To enable Jumbo Packet for the GigE camera:

  • in Spinnaker applications, change SCPS Packet Size (GevSCPSPacketSize) to 9000.
  • in Flycap2 applications, change Packet Size to 9000.

3. INCREASE PACKET DELAY TIME

  • in Spinnaker applications, decrease Device Link Throughput Limit (which indirectly increases packet delay time).
  • in FlyCap2 applications, increase Packet Delay.
関連記事