Demo entry 6324489

ex

   

Submitted by anonymous on Nov 20, 2016 at 08:26
Language: Python. Code size: 1.1 kB.

class RIP:

    HOST = "127.0.0.1"
    MAX_ROUTES_PER_UPDATE = 24
    DEFAULT_TIMER = 30
    TIMER_OFF_SET = 2


    def __init__(self, routerID, input_ports, outputs, timer):
        """
        HOST: the host IP address
        input_ports = the ports to listen on
        output_ports = the ports to send data thru
        """
        print("Starting up RIP router...")
        timer = timer
        self.routerID = routerID[0]
        if not timer:
            base_timer = self.DEFAULT_TIMER
        else:
            base_timer = timer[0]

        self.update_timer = base_timer
        self.garbage_collection_timer = base_timer * 4
        self.timeout_timer = base_timer * 6

        self.garbage_timer_on = False
        self.route_change = False

        self.activate_ifaces(input_ports, outputs)
        # self._last_update_time = datetime.datetime.now()
        self._routes = []
        localroute = RIPRouteEntry(address=self.routerID,
                        metric=0, nexthop=self.routerID)
        localroute.init_timeout()
        self._routes.append(localroute)

        self.running()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).