Skip to main content

Python Socket Not Reading UDP Packets on Jetson Hardware

II have UDP packets that are being sent to my device via an Ethernet connection. I am attempting to read them data using the socket library in Python (version 3.8.10); however, despite them being displayed on the device when I run tcpdump, my Python program never receives the data, and I'm not sure why.

I want to receive the data from my local port 2368; however, it is not working. I will provide more information below.


Here is the code that I'm using to read data from the socket that I'm interested in.

import socket
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as soc:
    soc.bind(("", 2368))
    data = soc.recv(2000) # I'm using an arbitrary buffer size
    print("Received Data!", data)

Main Issue: The hardware that I'm having trouble with running this code on is a Jetson Xavier with Ubuntu 20.04.5 LTS and Gnome 3.36.8 (I'm not exactly too sure what Gnome is). When I try to run the Python code above on this hardware, the soc.recv(2000) function blocks as it is unable to read data from the port, and it never reaches the print statement. However, when I run tcpdump in the command line, I get the following output.

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
15:07:29.621066 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.622382 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.623765 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.625010 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.626340 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.627667 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.628815 IP 192.168.1.201.8308 > 255.255.255.255.8308: UDP, length 512
15:07:29.628819 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.630328 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
15:07:29.631656 IP 192.168.1.201.2368 > 255.255.255.255.2368: UDP, length 1206
10 packets captured
24 packets received by filter
0 packets dropped by kernel

As a result, I believe that the Jetson (the computer I'm on) is receiving the UDP packets via the ethernet connection; however, for some reason, I'm unable to read it from the Python UDP server. If anybody has any suggestions on why this is occurring and if they have any suggestions on how to get this fixed, please let me know. I would just like to read the UDP packets via a Python program. I'm not sure if this is an error due to improper programs (I don't think this is the issue due to the additional information I provide below) or is somehow the networks between the Python program and the tcpdump command are split or a firewall is blocking them such as in this link here. I'm quite unfamiliar with Ubuntu, so if this is a firewall issue, I would appreciate some guidance on how to adjust the firewall to make this work out. I've attempted to disable ufw and add a rule to Thank you!


Additional Information: For some additional information, I attempted running this code on a 2019 MacBook Pro running MacOC Monterey (12.5.1) with the ethernet connection connected, and it ran perfectly fine where the blocking soc.recv(2000) call was able to return, and the print statement was reached. Below, I've listed what the tcpdump output looked like when the UDP packets were sent to the macbook. It makes me believe that my code is correct, but for some reason related to the OS or hardware, I'm unable to simply coy the code over onto the Jetson and run it appropriately.

There are some significant differences between the two tcpdump outputs between the Jetson (above which is not working) and the Macbook (below which is working), such as the mention of broadcasthost and opentable. I'm not entirely sure what these mean, so any help with my understanding of these would be greatly appreciated as well.

tcpdump: data link type PKTAP
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on pktap, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
15:47:32.528190 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.529466 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.530802 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.532092 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.533425 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.534734 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.536098 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.536350 IP 192.168.1.201.8308 > broadcasthost.8308: UDP, length 512
15:47:32.537433 IP 192.168.1.201.opentable > broadcasthost.opentable: UDP, length 1206
15:47:32.537868 IP 192.168.1.201.8308 > broadcasthost.8308: UDP, length 512
10 packets captured
16 packets received by filter
0 packets dropped by kernel

If there is any additional information that I can provide or any guidance on how to structure my question on Stackoverflow, please let me know, thank you!



source https://stackoverflow.com/questions/74585619/python-socket-not-reading-udp-packets-on-jetson-hardware

Comments

Popular posts from this blog

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

How to split a rinex file if I need 24 hours data

Trying to divide rinex file using the command gfzrnx but getting this error. While doing that getting this error msg 'gfzrnx' is not recognized as an internal or external command Trying to split rinex file using the command gfzrnx. also install'gfzrnx'. my doubt is I need to run this program in 'gfzrnx' or in 'cmdprompt'. I am expecting a rinex file with 24 hrs or 1 day data.I Have 48 hrs data in RINEX format. Please help me to solve this issue. source https://stackoverflow.com/questions/75385367/how-to-split-a-rinex-file-if-i-need-24-hours-data

ValueError: X has 10 features, but LinearRegression is expecting 1 features as input

So, I am trying to predict the model but its throwing error like it has 10 features but it expacts only 1. So I am confused can anyone help me with it? more importantly its not working for me when my friend runs it. It works perfectly fine dose anyone know the reason about it? cv = KFold(n_splits = 10) all_loss = [] for i in range(9): # 1st for loop over polynomial orders poly_order = i X_train = make_polynomial(x, poly_order) loss_at_order = [] # initiate a set to collect loss for CV for train_index, test_index in cv.split(X_train): print('TRAIN:', train_index, 'TEST:', test_index) X_train_cv, X_test_cv = X_train[train_index], X_test[test_index] t_train_cv, t_test_cv = t[train_index], t[test_index] reg.fit(X_train_cv, t_train_cv) loss_at_order.append(np.mean((t_test_cv - reg.predict(X_test_cv))**2)) # collect loss at fold all_loss.append(np.mean(loss_at_order)) # collect loss at order plt.plot(np.log(al...