SyntaxHighlighter

Thursday 15 August 2013

Day 43: ARP'ing about

Pi

Got the Pi problem on the move with Steve Pettifer's help. First we tried to arp-scan a Pi via a Ubuntu VM on a Windows Host, but the idea of trying to navigate the virtual network adapters to route the VM to the Pi was simply daunting and somewhat unnecessary.

So I used the Mac conveniently located behind me in the AIG lab instead, as Steve had previously successfully arp'ed a Pi from his Mac so we should know what we are doing. However even following Steve's tried and tested method did not work, the arp-scan still failing. Apparently the OS on this Mac treats internet connection sharing differently to the one on Steve's Mac.

So then I connected two Pi's together, one a master and the other a slave (i.e. it represents all the other Pi's that are going to be connected one at a time). Installed arp-scan on the master, tried it, but still no luck.

Finally we got David in to help out, and soon discovered that getting arp-scan to work meant we had to fully configure IP addresses for the master and slave Pi's. Luckily we are using the same SD card for all the slaves so we won't need to reconfigure anything each time. There isn't any DHCP device set up, so it is simpler to just statically assign IP addresses. This was achieved my modifying the /etc/network/interfaces file, replacing the line (on the master Pi):
iface eth0 inet dhcp

with:
iface eth0 inet static
    address 192.168.0.1
    netmask 255.255.255.0
    gateway 192.168.0.2

and similarly on the slave Pi (though of course the address and gateway will be different).

Now finally with a working arp, I set about coding the Python. Installed scapy (libraries for arp'ing and other useful network related stuff) and it's dependencies as per the website instructions.

In the Python script I noticed you need to first import scapy.all and then call from scapy.all import ... For some reason it doesn't work if you try to import the required bits directly.

Decided on this design specification for the function:

It will check for any unique new Pi being connected to the Master Pi via direct ethernet (Master and the new Pi must be using specifically modified SD cards that assign them the correct IP address) and whenever it finds one it will log it's MAC address and a newly generated sequence number to the log file. They will be on the same line, seperated by a comma e.g.
b7:56:d3:ff:32:11,13/0001

It will print useful info to the user as it runs, e.g. MAC and sequence for any new Pi, or a message saying that the Pi currently connected has already been logged. In addition it will support being stopped and restarted but still remembering which sequence number it was up to. In additional addition it will require a command line argument which is the current year, so that it can output the correct sequence number.

Sounds fun.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.