def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach them self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP) self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._msg_queue = collections.deque(maxlen=32) self._recv_thread = threading.Thread( target=self.read_socket_msgs_from_neighbours)
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() self._distance_table = {} # Map<Destination,[NextHop,TotalCost]> self._distance_table_lock = threading.Lock() self._neighbors = [] # List<Integer> # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None self._config_updater = None # a auto updater controller (PediodicClosure) # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # thread-safe. self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._config_updater = None self._send_updater = None self.distance_vector = {} self.neighbor_vectors = {} self.has_changed = True
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._config_updater = None self.neighbor_dvs = {} # neighbor id : {des : cost} self.dv = {} # {neighbor_id : cost} self.lock = threading.Lock() self.report_count = 0
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._lock = threading.Lock() # a list of (neighbors, next hop, cost) example [(1,1,0), (2,2,9), (3,3,9)] self._curr_neighbor_cost = [] self._start_time = None self._call_counter = 1 self._last_msg_sent = None self._fired_threads = []
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() # Stores distance from current router to neighbor, c(x, y) # It will only contain neighbors, which is different from forwarding table. self.neighbors_distance = {} # Stores the latest update message received from neighbors self.latest_update_message = {} # A list of tuples(dest_id,next_hop,cost), similar to the snapshot of # forwarding table. However, self.D = [] # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self, config_filename): # ForwardingTable has 3 columns (DestinationId,NextHop,Cost). It's # threadsafe. self._forwarding_table = table.ForwardingTable() # Config file has router_id, neighbors, and link cost to reach # them. self._config_filename = config_filename self._router_id = None # Socket used to send/recv update messages (using UDP). self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Remember neighbors self._neighbor_routers = [] # Listening thread. self._receive_update_message_thread = threading.Thread( target=self._receive_update_message) # Sending thread. self._send_update_message_thread = threading.Thread( target=self._send_update_message) self._prev_snapshot = []