replaying multicast UDP packet capture via tcpreplay not being seen by client - udp

I'm having no joy in getting a replayed UDP Multicast packet to be "seen" by a client program on a different machine.
Details:
I have two machines on my local (wired) network connected through one unmanaged switch. One machine (running tcpreplay) is running Ubuntu 20.04, the other machine is running Windows 10.
On the Windows machine I have a Python program I wrote which listens for UDP multicast packets on port 5110 (this is dictated by the source of the UDP stream which is a commercial program). When I run the commercial program, my Python code correctly consumes the incoming packets and all seems to be working fine. I have a lot of work yet to do on the contents of those packets after they are received, but that isn't important for this issue.
So, moving forward, I decided it would be great to be able to work on the Python code without having the commercial program always running in the background hogging up resources. I figured if I could catch a snippet of UDP broadcasts from that program, I should be able to replay at leisure without having to run that resource hog.
So, on the Windows machine, I captured a UDP multicast packet stream using Wireshark and saved to a pcap file which I then copied to the Ubuntu machine.
I then attempted to replay that pcap file (on the Ubuntu machine) as follows:
$sudo tcpreplay -i enp5s0 single.pcap
To my disappointment, my Python program (on the Windows machine) did not receive the incoming packets.
Back on the Windows machine, I fired up Wireshark again and captured the "replayed" packet coming from the Ubuntu machine - so it appears the packet did make it out of my Ubuntu machine and into my Windows one. The contents of both the source packet (sent by tcpreplay) and the received packet (grabbed by Wireshark) appear identical - including the source and destination MAC addresses and the checksums. A diff on the byte contents of each packet yields no differences.
However, my Python program still stoically sits there waiting at:
data, address = sock.recvfrom(1024)
Here on stackoverflow, I did find this thread which seems to be an identical problem, however none of the solutions presented within helped (including changing the rp_filter parameter). I also saw mention of a Windows program, "Colasoft PacketPlayer", which I tried - running on the same machine as my Python client. This appears to have the same apparent results (i.e. no joy). I did not initially try that route as I was concerned with generating the packet on the same machine which is listening for it. (As an aside, I did also capture the replayed packet from Colasoft PacketPlayer and it too appears identical to the source packet).
At this point I'm out of ideas and am reaching out to the community for possible next steps?

Related

USB CDC-ACM on STM32 device not registering on Linux

Working with the STM32L062 Cortex-M0 and CubeMX the generated USB CDC-ACM code works fine in Windows. With loopback code running on the STM32 and TerraTerm running on Windows characters typed in the terminal window correctly echo back. However, when this same system is then plugged into a laptop running Ubuntu, the device fails to enumerate. Even worse, the system doesn't appear to respond to the connection whatsoever- no new messages appear via dmesg that even a failed enumeration is going on. Given that the code used is generated by CubeMX wizards it is difficult to know what to start to troubleshoot. Any suggestions?
As an aside, this isn't the first issue presented by CDC-ACM drivers. Implementing a USB CDC-ACM stack for a PIC32MM processor, data can be sent to the host but not received from the host, however, if the driver is switched to plain vanilla CDC then data can be sent both ways no problem. So it seems maybe Ubuntu has some issues with the default USB drivers, but either way, it's very odd that the ST driver gets zero response at all from the system.

UDP Packets Lost (Ubuntu 18.04 into Windows 10)

I am trying to send UDP packets from Linux machine (Ubuntu 18.04 ) to a windows 10 machine. But the packets are not received at the Windows machine. I have already send UDP packets from Windows 10 to Linux machine and was successful. I have wireshark installed on both machines to debug. Pings are working from Linux to Windows as well.
The udp packets from Linux machine seems to be send as per Wireshark. However the wireshark on windows machine shows nothing regarding UDP packets from Linux machine. I have added inbound rules for the port on Windows machine, but still the issue persists. I have tried using different port numbers as well. Kindly let me know if there is anything missing from my end
The problem was due to active Symantec End Point Protection. So created an exception rule for the respective Sender IP address and everything works fine

Proper way to connect to IOT devices (UDP or ICMP)

What is the proper way to connect an app to a device? At the moment, I have a raspberry pi 3 that controls something about electricity and an iPhone app I created. Every time the app goes to foreground, it sends a UDP broadcast message, when the app receives a response from the raspberry pi, it uses that IP address (in the IP header) to consume the web services I created in the hub. This UDP process is done all the time you run the app. Is this what IOT devices usually do? I assume the raspberry pi IP will change sooner or later.
A colleague of mine told me another way: After the first time I get the IP address, instead of using UDP broadcast messages every time the app runs, use ICMP to ping the previously saved IP address to see if it is responding. In that case, I use the web services with that IP address, otherwise, use the UPD broadcast message again.
I don't see the point of that. Basically because the system is not faster using ICMP. (a UDP request is more or less as fast as an ICMP request). Moreover, maybe, another device started using that IP address now (like a smart TV or a smart plug) and for that reason, it is not going to reply to the network requests sent by the app. In that case, the app cannot recover, because it thinks it is already connected to the proper device. As far as I understand, ICMP is a protocol use for diagnosis, not for devices discovery.
What do you think? What's the process used by devices like Alexa, Philips Hue, Smart plugs... to solve the problem of discovering the devices by their apps?
It seems Philips HUE is using SSDP, which under the hood uses a UDP broadcast message. Is it used every time you run the app to discover the IP address? (I am going to check this later with wireshark)
Thanks for suggestions.
You can enable the hostname of your Raspberry Pi to be accessible on your local network through:
http://raspberrypi.local
To enable it, you need to install Bonjour support on your Raspberry Pi by installing the Avahi mDNS daemon (implements Apple's Zeroconf architecture):
$ sudo apt-get install avahi-daemon
Update boot startup:
$ sudo insserv avahi-daemon
Restart to apply the new configuration:
$ sudo /etc/init.d/avahi-daemon restart

Using iperf3 for measuring UDP throughput on STM32 board

I have STM3220G-Eval board with STM32F207 MCU. I've loaded UDP Echo Server lwIP based sample application (from CubeMX archive). This app used port #7. I've tried to use iperf3 in client mode (Windows OS), but it failed to work with the board (though Echotool successfully worked as a client). Can iperf3 work with custom UDP echo server?
Short answer: Not really. The iperf3 client and server need to communicate with each other over a control channel that is set up before the test starts. This allows them to exchange test parameters, ending conditions, and so on. If you wanted to make an iperf3 server on your embedded system, it would need to speak the (not very well documented) control protocol used by the iperf3 client.
iperf version 2 doesn't use a control channel; it might work for your application if all you need to do is send UDP packets to your board.
Bruce.

How can i emulate streaming data from a serial port?

I have a text file containing NMEA (GPS) data that I' like to replay to a COM port so the application I'm building can read it.
I considered writing a quick C# console app to loop over the file but I don't have any COM ports. This appraoch would require a virtual COM port and I'm not sure what challenges that would entail.
I also looked at GPSGate. Nice product but it doesn't seem to replay NMEA files over one of its virtual com ports.
How can I stream an existing text file to simulate GPS over a serial connection? I prefer a serial port, rather than mocking, to avoid reworking the application I'm developing and to facilitate use with other applications that use GPS over serial ports for which we don't have source code.
Update 1 - I downloaded a trial version of Virtual Serial Port Driver by Eltima and within a few minutes had some C# code writing to a serial port and appearing in Termite. Yes, it works but $100 seems excessive for what I'm trying to accomplish. Open source or free commercial would be preferred.
gpsfake is part of the gpsd project
gpsfake is a test harness for gpsd and its clients. It opens a pty (pseudo-TTY), launches a gpsd instance that thinks the slave side of the pty is its GPS device, and repeatedly feeds the contents of one or more test logfiles through the master side to the GPS. If there are multiple logfiles, sentences from them are interleaved in the order the files are specified.
You can port the output to a virtual serial via /usr/bin/gpspipe -r | socat - PTY,link=/tmp/gpsd.pty,raw using gpspipe, also from the gpsd project, to be picked up however you choose.
It is POSIX compliant.
You need a virtual serial port such as:
http://sourceforge.net/projects/com0com/
and a hyper terminal replacement.. in XP and earlier it was very easy with the shipped copy of hyperterminal as mentioned bellow..
You set up a virtual null modem connection
Null modem has a COM4 to COM5 Connection established as Null modem std gps is 4800Baud
Hyperterminal to COM5
Application to COM4
Copy paste your NMEA Values into Hyperterminal this isn't 1Hz like GPS though.. to enable 1Hz(or 1 line per second) you will need to find a different application than hyperterminal to send the messages at 1 second increments.