Message Boards Message Boards

[WSS17] Capturing Packets from a Network Interface

Posted 7 years ago

The aim of the project was to add support for capturing network packets on any particular interface to Mathematica. The functions should aid in debugging network problems and capturing packets which use TCP and UDP protocols.The idea is to create a new function which then invokes a c++ library in the background which starts sniffing packets. Based on the "time"and "protocol" variable set in the function parameter the library returns the packet data to Mathematica which can then be used to make inferences, plot graphs which in turn can be used in help in debugging network issues.

Functions which print out TCP, UDP, DNS data were added on the Mathematica side which use the "libtins" C++ library on the backend. The entire TCP/UDP packet is serialized and sent to Mathematica where it's parsed. Fields returned inside Source/Destination IP/Port, Checksum, Length, Headersize, ack, timestamp etc.

The same work can be extended to make it function real time where we are able to visualize the traffic in Mathematica. Sample result of TCP data capture

Above you can see all the field returned with their corresponding values. Possible use cases include checking response times for requests to a particular domain, a particular ip or even a particular port. With Mathematica's advance plotting features it's very easy to visualise the erroneous packet. The C++ library actually used in the backend can be found here. For the entire code visit my GitHub page.

Plots

Time vs Destination IP Time vs Destination IP SourceIP vs Payload Size SourceIP vs Payload Size

Attachments:
POSTED BY: Nikhil Ramesh
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract