Arduino Packet Sniffer using w5100 ethernet shield.

The code is based on Nicolas Humfrey’s W5100 Mac Raw project
ORIGINAL POST
By Infinite Loop Development Ltd
components
Hardware Components
w5100 Ethernet shield
X 1
Software Apps and online services
Arduino IDE
details

ucc_packet.PNG

It is often surprising how busy your home network is, even when you think nothing much is happening on it, our homes are filled with smart devices that chat constantly on the network, constantly announcing technical details about themselves. If you run Wireshark on your computer, you can see just how noisy the network is.

This bit of code sniffs packets off the network, using a Arduino and a W5100 based ethernet shield. Note that this is  will only pick up packets directed at the arduino, or broadcast packets, and since the serial interface is way slower than your network connection, expect plenty of dropped packets.

I’ve got the output to show human-readable text where possible, – filtering out the null character (0), which interfered with copy and pasting the output. There’s not much intellegence going on here, so there’s going to be IPv4 mixed with IPv6 and ARP frames here.

The code is based on Nicolas Humfrey’s W5100 Mac Raw project here https://github.com/njh/W5100MacRaw

#include “w5100.h”

const byte mac_address[] = {
0xae, 0x03, 0xf3, 0xc7, 0x08, 0x78
};

Wiznet5100 w5100;

void setup() {
// Setup serial port for debugging
Serial.begin(115200);
w5100.begin(mac_address);
}
uint8_t buffer[800];
void loop() {
uint16_t len = w5100.readFrame(buffer, sizeof(buffer));
if ( len > 0 ) {
for(uint16_t i=0; i<len; i++)
{
if (buffer[i]>0)
{
Serial.print((char)buffer[i]);
}
}
Serial.println();
}
}

ucc_packet.PNG

It is often surprising how busy your home network is, even when you think nothing much is happening on it, our homes are filled with smart devices that chat constantly on the network, constantly announcing technical details about themselves. If you run Wireshark on your computer, you can see just how noisy the network is.

This bit of code sniffs packets off the network, using a Arduino and a W5100 based ethernet shield. Note that this is  will only pick up packets directed at the arduino, or broadcast packets, and since the serial interface is way slower than your network connection, expect plenty of dropped packets.

I’ve got the output to show human-readable text where possible, – filtering out the null character (0), which interfered with copy and pasting the output. There’s not much intellegence going on here, so there’s going to be IPv4 mixed with IPv6 and ARP frames here.

The code is based on Nicolas Humfrey’s W5100 Mac Raw project here https://github.com/njh/W5100MacRaw

#include “w5100.h”

const byte mac_address[] = {
0xae, 0x03, 0xf3, 0xc7, 0x08, 0x78
};

Wiznet5100 w5100;

void setup() {
// Setup serial port for debugging
Serial.begin(115200);
w5100.begin(mac_address);
}
uint8_t buffer[800];
void loop() {
uint16_t len = w5100.readFrame(buffer, sizeof(buffer));
if ( len > 0 ) {
for(uint16_t i=0; i<len; i++)
{
if (buffer[i]>0)
{
Serial.print((char)buffer[i]);
}
}
Serial.println();
}
}

COMMENTS

Please Login to comment
  Subscribe  
Notify of
POSTED BY
TAGS