Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Cannot receive UDP packets

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
praju
Posts: 3
Joined: 2015-05-11 14:44

Cannot receive UDP packets

#1 Post by praju »

I am trying to build a socket to retrieve the ethernet packets from ECU(I do not know much about the ECU). When i run my code on windows there is no problem and the code runs correctly. But when i run my code on Debian it gets stuck at s.recv(1024).
I have already set static ip in /etc/network/interfaces as follows:

Code: Select all

iface eth0 inet static
address 160.48.199.91
netmask 255.255.255.0
gateway 160.48.199.254
The simple code is as below:

Code: Select all

 import socket
    import sys
    HOST = "160.48.199.91"
    port = 30490
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP)
    s.bind((HOST, 30490))
    while True:
         data = s.recvfrom(1024)
         print(data)
There is no LAN or Router. When i check netstat -s i see that there are 0 UDP and 0 TCP messages received. But when i check in Wireshark on Debian i could see the displayed UDP packets. Does it mean that the UDP packets are reaching the Raspberry Pi but not received by Debian ? Or are these packets being dropped ? What could be the problem ?
Please help me with this problem i urgently need it for my thesis. :cry:

User avatar
levlaz
Posts: 179
Joined: 2012-09-27 12:06
Location: San Francisco, CA

Re: Cannot receive UDP packets

#2 Post by levlaz »

Can you check out this python UDP Socket example that I made and see if it runs.

https://levlaz.org/programming-web-sockets-in-python/
Best,

Lev
Blog

マーズ maazu
Posts: 23
Joined: 2015-05-04 05:13
Location: kuala lumpur

Re: Cannot receive UDP packets

#3 Post by マーズ maazu »

Hi there, can you do a:
tcpdump -i eth0

and see if the screen start filling up with info? If there is nothing coming thru eth0, then you might need to update your firmware.

praju
Posts: 3
Joined: 2015-05-11 14:44

Re: Cannot receive UDP packets

#4 Post by praju »

Hello, I could see the udp messages after using the command "tcpdump -i eth0".

praju
Posts: 3
Joined: 2015-05-11 14:44

Re: Cannot receive UDP packets

#5 Post by praju »

levlaz wrote:Can you check out this python UDP Socket example that I made and see if it runs.

https://levlaz.org/programming-web-sockets-in-python/
When i run a client server program on PC and raspberry pi then it works. But when i run the previous code then again i cannot see any udp messages. The ECU is broadcasting the messages on a local multicast address. I tried to use multicast program to accept the messages but still its not working and shows 0 udp messages received in netstat -s :cry:

Post Reply