/packetSniffer-packetTransfer

A packet sniffer and overcome on lost packet, using JavaScript and Python

Primary LanguageJavaScript

How To Use

  1. Run "npm i" (installing the pack's for the current task).

  2. Run "npm run server"

  3. Open another cmd in same directory and insert "npm run client"

    • After that you should see in your server window the packets and the full message the client sent.

      • A random packet is lost in every 3 sec of message delivery.
      • In the example below you can see that the message divided into 3 packets while one of them was lost (packet number 1 was lost).

  4. At the same time, in the server window, you can see the packets that already delivered and their full message. As you can distinguish the full message is not the complete message.

    • After that, the app recognize the lost packet and restore that packet.
      • At the end of the connection you can see the complete message after the lost packet restore.

The sniffer

  1. Open another cmd window in same directory and insert "npm run sniffer"

    ===ONLY FOR WINDOWS===

    *Note: if a dialog box appear -> click yes.

    • Now you see the sub window :

      In this screen you should choose the 127.0.0.1 option (in my case its '5')

      • After that you need to press Enter button on keyboard

      • Then the sniffing is start:

        *Note: to stop sniffing press 'ctrl+c'.

        • Now your sniffer got the UDP packets:

    ===For Linux/Windows===

    For Linux I used the 'scapy' pack of python:

    After "npm run sniffer" -> you should see the a async packet capture.

    If you stop the sniffing you can see the log file in "sniffLog.txt"

    NOTES:

    • The project codded in nodeJS .
    • Sometimes if you dont have wincap working properly in your Windows OS, then problems with capturing may happen, so for windows OS I used RawCap.exe (see code/documentation).
    • For Linux I used 'scapy' package for python (I codded a python script that invoke from the js code).