in reply to getting mac address

Basically you'll have to read your system's ARP table and match that up with the source IP. The simplest thing is to parse the output of the arp command, or possibly netstat -nr depending on your OS (for UNIX-y values of OS, of course).