Code Monkey home page Code Monkey logo

packet_racer's Introduction

Packet racer

A CLI project demonstrating packet transfer speed of various UDP (User Datagram Protocol) techniques. This includes net.Dial, AF_INET, AF_INET raw socket, AF_PACKET methods. Allows the user to set option values for port no., packet size, duration for each method.

It then compares the performance of each method in terms of number of packets transferred and Mega Bytes transferred and arranges them in descending order.

First Image

Build It Locally

Pre Requisites

  • Currently works only on Ubuntu/Linux
  • Needs GO already Installed

Clone the repository using the following command

git clone https://github.com/jaydee029/packet_racer

Move into the root folder, and build the project

cd packet_racer
go build -o packet

Now You can run the binary within the folder with or without flags li

sudo ./packet

Root privileges are required to run the binary, since certain methods such as raw sockets require root permissions.

To run the program globally add the binary to your globally path

Functionality Available

Optional Flags

  • -duration : allows you to change the duration for which each method runs. By default this value is set to 1 Second
  • -port : allows the user to change the port at which the listening server spins off/ By default this value is set to 8080
  • -size : allows you to change the size of packets being sent across in the udp connection. By default it has its value set to 1470 bytes

How It Works

The program uses netcat to start the listening server at the given Port, the server runs for some given time, The udp methods are invoked synchronously on the same listener server, once the connnection is established the transfer of IP packets begin.

  • The net.Dial Method: It is baseline implementation provided by the net library in golang , whoch allows connecting to a udp connection, and transfer ip packets by specifying the portnumber and the ip address.
  • AF_INET Method: using the syscall method which is the underlying method used in the baseline implementation, we manually specify the use of AF_INET packet, specify the IP socket format and destination port and ip address. This method is generally faster than the baseline implementation.
  • AF_INET Raw Socket Method: uses the syscall method similar to the AF_INET implementation, but instead using a predefined IP packet, an ip packet is constructed from scratch, source and destination ports as well as ip address, message size in bytes are specified while constructing the packet.
  • AF_Packet Method: Uses the syscall method along with the AF_Packet method using a raw socket similar to the above method, it may require a source and destination mac address as well as an ethernet header along with the already specified options. This method is usually the fastest among the above methods.

packet_racer's People

Contributors

jaydee029 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.