Code Monkey home page Code Monkey logo

router_simulator's Introduction

router_simulator

Router:

A network router is a device which knows where to send which packet,. So if we define that any packet for network address 1.1.1.1 to be sent to network device A, so it will forward every packet for 1.1.1.1 to device A. Apart from these rules a network router has a default gateway defined, so if a packet does not match any rule it will send that to default gateway.

A network rule is defined by providing an IP Address followed by their netmask and a destination machine, at the end followed by default gateway (optional)

You need to write a simple router simulator, which will be take input in terms of number of routing rules followed by routing rules and then number of route statements and followed by route statements. Your output will be routed destination and if it can not route some packets then output should print NO ROUTE DEFINED

Sample Input:

3 10.0.0.0 255.255.255.0 192.168.1.1

20.0.0.0 255.0.0.0 192.168.1.2

default 192.168.1.3

5

10.0.0.2

10.1.1.2

20.1.1.2

20.1.1.1

21.1.1.1

Sample Output:

192.168.1.1

192.168.1.3

192.168.1.2

192.168.1,2

192.168.1.3

Sample Input:

1

10.0.0.0 255.255.255.0 192.168.1.1

3

10.0.0.2

10.1.1.2

10.0.1.0

Sample Output:

192.168.1.1

NO ROUTE DEFINED

NO ROUTE DEFINED

router_simulator's People

Contributors

csaurav avatar

Watchers

 avatar  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.