Wireshark using the Nokia LCD
Purpose: To use the Nokia LCD to display various network information such as source IP address, destination IP address, protocol name, and packet length from captured Packets. NokiaLCD library and regular mbed library have been used to create this program.
Components:
- Ethernet Breakout board
- Nokia micro LCD (6610)
Wireshark
#include "mbed.h" #include <string> #include "NokiaLCD.h" NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type DigitalOut myled(LED1); Ethernet eth; //Determine the protocol from the protocol number string Protocol(int num){ string s; switch(num){ case 17 : s="UDP"; break; case 1 : s="ICMP"; break; case 6 : s="TCP"; break; case 89 : s="OSPF"; break; case 2 : s="IGMP"; break; case 103 : s="PIM"; break; default : s="None"; } return s; } int main() { int number=0; int type; char ver, prot; char hlen; char servtype; short tot_len,ident; string k; myled=1; int loc = 1; char buf[0x600]; //Set the buffer for incoming packets int* length=(int *)(buf+12); //Find the packet length while(1) { myled=!myled; int size = eth.receive(); //Determine the packet size //If the packet size is zero then execute the loop if(size > 0) { loc=1; eth.read(buf, size); type=(buf[12]<<8|buf[13]); ver= buf[14]>>4; hlen=buf[14]&0xF; servtype=buf[15]; tot_len=(buf[16]<<8|buf[17]); ident=(buf[18]<<8|buf[19]); prot=buf[23]; //Check for IPv4. Filter out the rest if(type==0x800){ lcd.background(0x0000FF); //Set the background color lcd.cls(); lcd.locate(0,1); //print stuff lcd.printf("Wireshark on Nokia"); loc+=2; lcd.locate(0, loc); number++; lcd.printf("Number:%i",number); loc+=1; lcd.locate(0, loc); lcd.printf("Source: "); loc++; lcd.locate(0, loc); lcd.printf("%d.%d.%d.%d", buf[26], buf[27], buf[28], buf[29]); //Print the source IP address from the buffer loc+=2; lcd.locate(0, loc); lcd.printf("Destination: "); loc++; lcd.locate(0, loc); lcd.printf("%d.%d.%d.%d", buf[30], buf[31], buf[32], buf[33]); //Print the destination IP address from the buffer loc++; lcd.locate(0, loc); k=Protocol(prot); lcd.printf("Protocol %s",k); loc+=2; lcd.locate(0, loc); lcd.printf("Length:%i",size); }else{ //Else print no connection printf("No Connection");} wait(1); } } }
Import programWireshark
Wireshark for Nokia LCD
Please log in to post comments.