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

Prop `className` did not match in next js app

I have written a sample code ( Github Link here ). this is a simple next js app, but giving me error when I refresh the page. This seems to be the common problem and I tried the fix provided in the internet but does not seem to fix my issue. The error is Warning: Prop className did not match. Server: "MuiBox-root MuiBox-root-1" Client: "MuiBox-root MuiBox-root-2". Did changes for _document.js, modified _app.js as mentioned in official website and solutions in stackoverflow. but nothing seems to work. Could someone take a look and help me whats wrong with the code? Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

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

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console