Giter Site home page Giter Site logo

pyt's Introduction

PyPT

(somewhat reimplementation of) packet tracer in python

A (during 11/08/2017) bare-bones implementation of Packet Tracer (created by Cisco Systems) which at the final alpha development stage should implement several hardware recreations into the program for usage as nodes/network I/O devices such as:

  • PC
  • Laptop
  • Smart phone
  • Links
  • Routers
  • Switches

And more pretend items such as Networks which combine any form of physical hardware device into one local subnet, in the generic case the network would have a default gateway where all traffic is routed to if a route is not found within the local routing tables, and that router would (in the focus of the Internet topology) have an external address from the Network (such as a public IP address) for other networks to communicate with.

An example code-base would look something like this: (dated 11/08/2017)

Example topology

from network.router import Router
from network.network import Network
from network.link import Link
from network.ethernet import Ethernet


network = Network("Network 1")

router1 = Router(
           network=network,
           ip_addr="0.0.0.1",
           is_gateway=False,
           mac_addr="00:00:00:00:00:00",
           label="Router 1"
           )

router2 = Router(
           network=network,
           ip_addr="0.0.0.2",
           is_gateway=False,
           mac_addr="00:00:00:00:00:01",
           label="Router 2",
           )

router3 = Router(
           network=network,
           ip_addr="0.0.0.3",
           is_gateway=False,
           mac_addr="00:00:00:00:00:02",
           label="Router 3",
           )


Link(router2, router1)
Link(router3, router1)

#    [router 2]    [router3]
#         \          /
#          \        /
#          [router1]

r2_data = Ethernet(
    dst_mac=router3.mac_addr,
    src_mac=router2.mac_addr,
    data="this data is from router 2",
)

r1_data = Ethernet(
    dst_mac=router3.mac_addr,
    src_mac=router1.mac_addr,
    data="this data is from router 1",
)

router2.discover("0.0.0.3")
router2.send_data("0.0.0.3", r2_data)
router1.send_data("0.0.0.3", r1_data)
print router3.data_queue

Which'd output:

>>> [<Ethernet Packet (src=00:00:00:00:00:01) (dst=00:00:00:00:00:02) (data=this data is ...)>,
...  <Ethernet Packet (src=00:00:00:00:00:00) (dst=00:00:00:00:00:02) (data=this data is ...)>]

pyt's People

Stargazers

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