Cannot receive UDP packets

Need help with C, C++, perl, python, etc?

Cannot receive UDP packets

Postby praju » 2015-05-11 14:51

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:
praju
 
Posts: 3
Joined: 2015-05-11 14:44

Re: Cannot receive UDP packets

Postby levlaz » 2015-05-11 21:24

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
User avatar
levlaz
 
Posts: 179
Joined: 2012-09-27 12:06
Location: San Francisco, CA

Re: Cannot receive UDP packets

Postby マーズ maazu » 2015-05-12 01:18

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.
マーズ maazu
 
Posts: 23
Joined: 2015-05-04 05:13
Location: kuala lumpur

Re: Cannot receive UDP packets

Postby praju » 2015-05-12 07:48

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

Postby praju » 2015-05-12 07:56

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:
praju
 
Posts: 3
Joined: 2015-05-11 14:44


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable