Python Client hangs on Multicast socket.recvfrom() on linux

NatNet, VRPN, TrackD, and Plugins
Post Reply
Marek
Posts: 6
Joined: Wed Dec 21, 2016 5:16 am

Python Client hangs on Multicast socket.recvfrom() on linux

Post by Marek »

I am using Python 3.5, Motive 1.10.1 and NatNetSDK 2.10 on ubuntu 16.04.1 lts

Motive is streaming the packets to multicast address which I can read using tcpdump.

The example PythonClient.py is not showing any frame data.

The issue seems to be in NatNetClient.py which hangs while trying to receive data from the socket.
socket.recvfrom(...) function waits to receive data, which I can see being streamed to the multicast address.

Both the address reuse
result.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
and membership
result.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
are present in the code and the socket client is created fine.

Is there an additional step required on linux that I am missing?

On windows (as local loopback stream) the python client would occasionally not work until i started a winFormsTestApp.exe but that might be unrelated
ryanhaun
Posts: 6
Joined: Tue Dec 27, 2016 11:11 am

Re: Python Client hangs on Multicast socket.recvfrom() on li

Post by ryanhaun »

Hi Marek,

It's a bit deceiving but the client will initialize without actually being connected to the server. It just means it's established. The fact that local loopback is giving you troubles in indication of a setting or network problem, not particular to the python client most likely. There might be some settings blocking network communication, have you tried unicast? Also if your using an older version of Motive, I'd suggest upgrading to the latest as we had some problems with errant settings that would persist. When installing Motive make sure to remove the persistent files in C:\ProgramData\optitrack. This will hopefully reset everything. In addition don't use older project files, just to be sure.

If you feel there is an issue with the python client, run it locally as well (local loopback & using the local IP directly). This should eliminate the network from the equation.

Let me know how it goes.

Ryan Haun
OptiTrack Support
Marek
Posts: 6
Joined: Wed Dec 21, 2016 5:16 am

Re: Python Client hangs on Multicast socket.recvfrom() on li

Post by Marek »

Hi Ryan,

My motive version is 1.10.1.3, according to the product updates web check it is the latest version.
And I am using a fresh project.

I have tried a windows box on the exact same network configuration and the sample winforms demo worked as well as the python client.

On my linux machine I am able to see the packets on the network (using tcpdump -XX) and they are populated with data, see APPENDIX 1.

The local loopback still waits to receive the data on the host box.


The worst part is that the Python client gets a response from the server if NAT_REQUEST_MODELDEF is sent, so I can view the model definitions , but it returns NAT_UNRECOGNIZED_REQUEST if I send NAT_REQUEST_FRAMEOFDATA.

Given that it works-ish on command port 1510 and I see the packets on multicast port 1511
It would mean that there would have to be a setting not permitting acquisition of multicast packets
within python.

Are you aware of any settings that might need changing (other than the ones in my sysctl.conf APPENDIX 2 and 3)?

Cheers,
Marek

#APPENDIX 1 - example packet
14:58:04.708697 IP 192.168.255.101.1511 > 239.255.42.99.1511: UDP, length 458
0x0000: 0100 5e7f 2a63 0050 fca3 439e 0800 4500 ..^.*c.P..C...E.
0x0010: 01e6 7023 0000 0211 6c73 c0a8 ff65 efff ..p#....ls...e..
0x0020: 2a63 05e7 05e7 01d2 67b5 0700 c601 e9bb *c......g.......
0x0030: 1400 0200 0000 5269 6769 6442 6f64 7920 ......RigidBody.
0x0040: 3100 0300 0000 5580 813b 2b1c ae3d 7e92 1.....U..;+..=~.
0x0050: 883f 9e07 503e d4c4 1a3d 34ad 813f 8d3f .?..P>...=4..?.?
0x0060: d73d 171c 6b3d 11f3 833f 616c 6c00 0300 .=..k=...?all...
0x0070: 0000 5580 813b 2b1c ae3d 7e92 883f 9e07 ..U..;+..=~..?..
0x0080: 503e d4c4 1a3d 34ad 813f 8d3f d73d 171c P>...=4..?.?.=..
0x0090: 6b3d 11f3 833f 0400 0000 9ab1 363f c8e8 k=...?......6?..
0x00a0: 4a3d 306d 813f 44bd ae3f 570a 473d ef5c J=0m.?D..?W.G=.\
0x00b0: 813f 32ae 96be 40d4 33be 68e0 913d 5392 .?2...@.3.h..=S.
0x00c0: 9dbe 40cf d7bc 4069 f5bb 0100 0000 0100 ..@...@i........
0x00d0: 0000 9b43 d53d 9f48 763d eebc 843f e9d4 ...C.=.Hv=...?..
0x00e0: 1f3b bdc5 e7b9 8eec 32ba caff 7fbf 0300 .;......2.......
0x00f0: 0000 5580 813b 2b1c ae3d 7e92 883f 9e07 ..U..;+..=~..?..
0x0100: 503e d4c4 1a3d 34ad 813f 8d3f d73d 171c P>...=4..?.?.=..
0x0110: 6b3d 11f3 833f 0100 0000 0200 0000 0300 k=...?..........
0x0120: 0000 a882 323d ed76 323d 6f0e 333d abe6 ....2=.v2=o.3=..
0x0130: 0f39 0100 0000 0000 0700 0000 0100 0100 .9..............
0x0140: 5580 813b 2b1c ae3d 7e92 883f a882 323d U..;+..=~..?..2=
0x0150: 0200 0200 0100 9e07 503e d4c4 1a3d 34ad ........P>...=4.
0x0160: 813f ed76 323d 0200 0300 0100 8d3f d73d .?.v2=.......?.=
0x0170: 171c 6b3d 11f3 833f 6f0e 333d 0200 580a ..k=...?o.3=..X.
0x0180: 0000 9ab1 363f c8e8 4a3d 306d 813f e9de ....6?..J=0m.?..
0x0190: 333d 0200 5a0a 0000 44bd ae3f 570a 473d 3=..Z...D..?W.G=
0x01a0: ef5c 813f 49b2 2e3d 0200 5e0a 0000 32ae .\.?I..=..^...2.
0x01b0: 96be 40d4 33be 68e0 913d 44a8 ae3c 0200 ..@.3.h..=D..<..
0x01c0: 5f0a 0000 5392 9dbe 40cf d7bc 4069 f5bb _...S...@...@i..
0x01d0: bcab a23c 0200 0000 0000 d18e 6a3e 0000 ...<........j>..
0x01e0: 0000 0000 0000 5555 5555 c51d c640 0000 ......UUUU...@..
0x01f0: 0000 0000

#APPENDIX 2 systemctl.conf

#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
# Enabling this option disables Stateless Address Autoconfiguration
# based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
net.ipv4.conf.all.accept_redirects = 1
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
net.ipv4.conf.all.secure_redirects = 0
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
net.ipv4.conf.all.accept_source_route = 1
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#
# Allow broadcasts
net.ipv4.icmp_echo_ignore_broadcasts = 0
# Allow non local bind
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.neigh.enp2s0.mcast_resolicit = 1



#APPENDIX 3 - ifconfig

enp2s0 Link encap:Ethernet HWaddr e8:11:32:d5:c0:4e
inet addr:192.168.255.2 Bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::ff64:6fa8:cb8e:9b43/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1421354 errors:0 dropped:14 overruns:0 frame:0
TX packets:3779 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:564152708 (564.1 MB) TX bytes:446254 (446.2 KB)
ryanhaun
Posts: 6
Joined: Tue Dec 27, 2016 11:11 am

Re: Python Client hangs on Multicast socket.recvfrom() on li

Post by ryanhaun »

Hi Marek,

We've tested on a clean build of Ubuntu and Python 3. It seems the sample is working in several cases out of the box without the need to configure anything in Linux.

I'm not sure what this problem is, maybe update to the latest Ubuntu and Python 3 if you haven't already?

Ryan Haun
OptiTrack Support
Marek
Posts: 6
Joined: Wed Dec 21, 2016 5:16 am

Re: Python Client hangs on Multicast socket.recvfrom() on li

Post by Marek »

I have indeed tried latest Ubuntu and python 3.5.3.0, and SLED 12 with python 3.4.1 I can get body descriptions, it fails to get frame data (unrecognised request 100)

I can replicate the issue on windows 10 and winpython 3.5.2.3
And I get the same results.

At the same time the C based packetClient obtains all the frames correctly.

Could it be that python version requires dhcp?

I have attached the screenshot of Windows test.

Do you have a linux example of the C packetClient implementation?

Cheers,
Marek
Attachments
Screenshot of the packetclient and pythonClient running + view on the line added to pythonclient
Screenshot of the packetclient and pythonClient running + view on the line added to pythonclient
client.png (92.24 KiB) Viewed 5348 times
Post Reply