This document illustrates when packet loss happens, and bring out a way to avoid that.
Run demo appdemo_online
, and check if it prints normal count of points.
- Mechenical LiDARs should have a count close with its theoretical count. If it jump up and down, packet loss may happen.
- M1 LiDAR should always have a count equal with its theoretical count, else packet loss happens.
To observe multiple LiDARs case, open multiple terminals, and run multiple demo_online
. Check if every LiDARs prints normally.
Packet loss may happens in below cases.
- on some platforms, such as Windows and embedded Linux
- Multiple LiDARs
- CPU resources is busy.
The solution is to increase the receiving buffer of MSOP Packet Socket.
in CMakeLists.txt
,CMake macro ENABLE_MODIFY_RECVBUF
enable this feature.
option(ENABLE_MODIFY_RECVBUF "Enable modify size of RCVBUF" OFF)
The code is as below. Please test it in your cases, and change buffer size to a good value.
#ifdef ENABLE_MODIFY_RECVBUF
{
uint32_t opt_val = input_param_.socket_recv_buf, before_set_val,after_set_val = 0;
if(opt_val < 1024)
{
opt_val = 106496;
}
socklen_t opt_len = sizeof(uint32_t);
getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&before_set_val, &opt_len);
RS_INFO << "before: recv buf opt_val:" <<before_set_val << std::endl;
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&opt_val, opt_len);
getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&after_set_val, &opt_len);
RS_INFO << "aftert: recv buf opt_val:" <<after_set_val << std::endl;
}
#endif
On some platforms, such as Ubuntu, the maximum value of the receiving buffer is restricted, and setsockopt() may fails.
To enlarge the maximum value, run this command. It change the value to 851,968 bytes.
sudo bash -c "echo 851968 > /proc/sys/net/core/rmem_max"