For this post, I’m going to assume you are already somewhat familiar with WireShark/tcpdump for monitoring network traffic.
Wireshark is great for viewing packets, but it only sees the traffic coming to/from the system that is running it.
Generally, that is OK. If I want to what traffic coming from my Arduino to a web server, I run wireshark on the webserver and I can see see the traffic fine. 99% of the time, that is what I need to do and it works great.
Every once in a while, like today, I am having totally bizarre problems with the arduino and I want to see EVERY packet it transmits to try and find a clue to the bizzaro behavior I’m seeing. But I can’t run wireshark on an arduino so my normal tool fails.
Modern ethernet networks use switches to transmit packets. Switches look at the MAC address each packet and transfer them to the proper port on the switch so only that port gets traffic for the attached device. For example:
If you are running wireshark on PC B, you cannot see the traffic between PC A and the router.
There are some switches that will let you replicate traffic from one port to another. If I were using one of those switches, in this example, I could replicate port A to port B which would allow PC B to see PC A’s traffic. It used to be only high end switches had this feature. I’ve been out of the corporate network world for a while now, so I don’t know if the price of any switch with this ability is anywhere reasonable now. But I do know no consumer switch I’ve seen has this ability.
In the early days of ethernet, we didn’t have these smart switches. We had dumb hubs. Hubs blindly transmitted all traffic onto all ports:
If a hub were used in place of a switch, then PC B can see PC A’s traffic.
And that is how I monitor network traffic to dumb devices: I use a hub as a ‘wire splitter’ allowing me to connect a laptop to the Arduino so all network traffic can be monitored:
I’ve done this for many years and it works great. The only possible ‘problem’ is that hubs tend to run at 10BaseT (10mbit). But rarely do I need speed, I just need to see what is happening.
The real issue is finding a hub. I don’t know of anyone making them new any longer. You will almost certainly have to go to ebay to find one. Check very carefully to verify it is really a hub and not a switch. It should support the old 10BaseT protocol, not the more recent fast ethernet (100Base-T*). Fast ethernet is switched and that is not what we want.
I’ve been using an HP Advancestack Hub 8E since sometime in the 90’s (it is so old it has a thinnet BNC connector as well):
Netgear used to make a nice steel cased 4 port hub as well. It was as small as their current 4 port models which was handy.
Lastly, notice on the HP hub the Cascade Port. You could not hook a hub/switch to just any port on these old hubs. You would connect the uplink switch/hub cable into the cascade port. As I recall, this jack simply had the tx/rx pairs reversed because there was no auto sensing.