Giter VIP home page Giter VIP logo

robert-ml / router-packet-simulator Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 627 KB

Used the Internet Protocol (IP) and the Ethernet/Industry Protocol (IP, I know, funny coincidence) to implement the ARP and ICMP protocols on a simulated router. The really nice part is the lookup time in the routing table that is very efficient. The lookup time is asymptotically O(1) by using the following data structure: a vector of 32 elements, and those elements are hash-tables. A position in the vector represents the network mask and there are only 32 possible network masks (practically there are only 31 but to be rigorous I implemented for 32) and for an incoming packet I must find on which interface to send it by making a logical AND between the destination IP and a network mask, prioritizing the smaller masks first. So I start in the vector from the 32nd element and see if the result of destination_IP & mask is in the hash-table. If it is, I found where to send the package. If not, I look further at the bigger masks. TLDR: because I hold my information in a vector of size 32 which has hash-tables as it's elements and my information is in those hash-tables, I can extract the information in a constant time.

Makefile 1.56% Shell 0.33% Python 57.63% C 4.58% Objective-C 1.11% C++ 34.80%

router-packet-simulator's People

Contributors

robert-ml 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.