def __init__(self, addr, heartbeatTime):
        """TODO: add your own class fields and initialization code here"""
        Router.__init__(self, addr)  # initialize superclass - don't remove
        self.heartbeatTime = heartbeatTime
        self.last_time = 0
        # Hints: initialize local state

        #forwarding table initialization
        self.forwarding_table = {
        }  #forwarding table consisting of addresses to neighbors of current router. Index is the destination node, and value is port number

        #graph initialization
        self.G = nx.Graph(
        )  #Initialize a Graph that would map the neighbors of current router, Directed because there may be different weights to and from routers based on traffic
        self.G.add_node(str(addr))  #add crrent node initially to the Graph

        #link state initialization
        self.link_states = {
        }  #The link state of a router contains the links and their weights between the router and its neighbors

        #Holds port numbers as values and endpoints as keys, and used to determine neighbors within link state
        self.new_links = {
        }  #this holds names of neighbors as indices and their port numbers as values
        self.port_to_link = {
        }  #this holds port numbers as indices and names of neighbors as values,
        self.link_costs = {
        }  #this array holds the cost of immediate neighbors and any new link

        #sequence number initialization
        self.sequence_numbers = {
        }  #this array holds the node this node is interacting with as indices and sequence numbers of the last encounter as the value
        self.last_seqnum = 0  #initialize last sequence number as 0 to start and it goes up after each broadcast

        pass
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     self.DEST={}
     self.Inf=16
Beispiel #3
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     pass
Beispiel #4
0
    def __init__(self, addr, heartbeatTime):
        """TODO: add your own class fields and initialization code here"""
        Router.__init__(self, addr)  # initialize superclass - don't remove
        self.heartbeatTime = heartbeatTime
        self.dist_table = {self.addr: {'port': -1, 'distance': 0}}

        self.debug_list = []
Beispiel #5
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.last_time = 0
     self.heartbeatTime = heartbeatTime
     self.addr = addr
     self.table = {}  # {addr: {cost:, nextHop: addr, port: }}
     self.infinity = 16
Beispiel #6
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.routersPort = {}
     self.routersCost = {}
     self.routersNext = {}
     self.routersAddr = {}
     self.heartBeat   = heartbeatTime
     self.last        = None
Beispiel #7
0
 def __init__(self, addr, heartbeatTime):
     """class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.routersNext = {}  # key》当前节点可到达的所有节点;value》以key作为目标根节点时最短路径中上一个节点
     self.routersCost = {}  # key》当前节点可到达的所有节点;value》以key作为目标根节点时最短路径的总权重
     self.routersPort = {
     }  # key》当前节点的所有邻居节点的名称(字母);value》key所表示的节点的编号(整数),编号值是根据节点名称ascii码值排序依次设为1,2,...
     self.routersAddr = {}  # 把 self.routersPort 的key和value交换一下
     self.heartbeat = heartbeatTime
     self.lasttime = None
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     self.G = Graph(undirected=True)
     self.SeqNum = {}
     self.Neighbours = {
     }  #Dictionary with key as address and cost and seqnum as values
     self.Curr_Seq = 0
 def __init__(self, addr, heartbeatTime):
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.forward_table = {}  # dst_addr, (port, cost)
     self.local_link_state = {}  # neighbor->(port, cost)
     self.received_link_state = {
     }  # map: node_num->(seq_num, local_link_state)
     self.seq_num = 0
Beispiel #10
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.distance_vector = {}  # { destination: { via: cost } }
     self.received_distance_vector = {
     }  # { neighbor: { destination: { via: cost } } }
     self.neighbors = {}  # { node: ( port, cost ) }
Beispiel #11
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.fwd_table = {}  # Format is dstAddr:port
     self.link_state = {self.addr: 0}  # Format is addr:cost
     self.neighbors = {}  # Format is addr:port
     self.seq = 0
     self.G = nx.Graph()
     self.G.add_node(0)
Beispiel #12
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time=0
     self.addr=addr
     self.sequence=0
     self.state=[]
     self.forward_table={}
     self.graph=Graph(undirected=True)
     self.add_status=True
     self.last_seq={}
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.addr = addr
     self.heartbeatTime = heartbeatTime
     self.lastTime = 0
     self.neighbors = {}  # {endpoint: {port, sequence}
     self.graph = {}  # directly connected neighbors: cost of link
     self.packets = {}  # {addr: packet}
     self.tentative = {}
     self.confirmed = {addr: {'cost': 0, 'nextHop': None}}
     self.mysqn = 0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     # so it has a destination address, a nextHop, a cost
     # use dictionary,router has a table
    
     self.routing_table = {}
     self.hearbeatTime = heartbeatTime
     self.lastTime = 0
     self.infinity = 16
     self.neighboursPort = {}
     self.neighboursAddr = {}
Beispiel #15
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     self.forwarding_table = {}
     self.routing_table = {}
     self.graph = Graph()
     self.seqno = "1"
     self.check = True
     # Hints: initialize local state
     pass
Beispiel #16
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.seq_num = 0
     # Yeah, NetworkX is fancinating!
     self.G = nx.Graph()
     self.G.add_node(self.addr)
     self.forward_table = dict()  # address (string) -> port (int)
     self.ports = dict()  # port (int) -> address (string)
Beispiel #17
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.link_state = {}  #APNA LINK STATE
     self.link_state_local = {}  #BAKI SUB KA LINK STATE
     self.sequence_number = 0  #SEND KARTAY WAKT SEQ NUM
     self.check_sequence_number = {}  #RECIEVE KARTAY WAKT SEQ NUM
     self.network_graph = Graph(undirected=True)  #GRAPH
     self.forwarding_table = {}  #FRWD TABLE
    def __init__(self, addr, heartbeatTime):
        """class fields and initialization code here"""
        Router.__init__(self, addr)  # initialize superclass - don't remove
        self.routersLSP = {}  ###
        self.routersAddr = {}  ###
        self.routersPort = {}  ###
        self.routersNext = {}  ###
        self.routersCost = {}  ###
        self.seqnum = 0  ###
        self.routersLSP[self.addr] = LSP(self.addr, 0, {})

        self.lasttime = None
        self.heartbeat = heartbeatTime
Beispiel #19
0
 def __init__(self, addr, heartbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
     self.heartbeatTime = heartbeatTime
     self.last_time = 0
     # Hints: initialize local state
     self.dis_vec = defaultdict(
         lambda: INF)  # address (string) -> distance (int)
     self.dis_vec[self.addr] = 0
     self.forward_table = defaultdict(
         lambda: None)  # address (string) -> port number (int)
     self.ports = defaultdict(
         lambda: [None, INF, None]
     )  # port number (int) -> [address (string), cost (int), distance vector (dict)]
Beispiel #20
0
    def __init__(self, addr, heartbeatTime):
        """class fields and initialization code here"""
        Router.__init__(self, addr)  # initialize superclass - don't remove
        self.routersLSP = {}  ###
        self.routersAddr = {}  ### key》端口号;value》邻居节点名称
        self.routersPort = {}  ### key》邻居节点名称;value》端口号
        self.routersNext = {}  ###
        self.routersCost = {}  ###
        self.seqnum = 0  ###
        self.routersLSP[self.addr] = LSP(self.addr, 0,
                                         {})  # 以self.addr初始化作为LSP的第一个元素
        # 每个路由节点针对以每一个节点作为源根节点生成的LSP单独存放一个LSP

        self.lasttime = None
        self.heartbeat = heartbeatTime
Beispiel #21
0
    def __init__(self, max_forks=0, prespawn=False, homogeneous=True):
        """
        max_forks: The maximum number of forks (default: 0 - unlimited)
        prespawn: Spawns and feeds forks before processing begins.
        homogeneous: Attempt to keep forks limited to one pattern
        """

        Router.__init__(self)

        self.max_forks = max_forks
        self.prespawn = prespawn
        self.homogeneous = homogeneous

        self.pattern_assignments = {}
        self.forks = []
        self.data = {}

        self.processing = False
    def __init__(self, addr, heartbeatTime):
        """TODO: add your own class fields and initialization code here"""
        Router.__init__(self, addr)  # initialize superclass - don't remove
        self.neighbours = {}
        self.tentative = {} 
        self.confirmed = {} # this is equivalent to routing_table in DV
        self.confirmed[addr] = {'cost' : 0, 'nextHop' : "", 'justAdded' : True} # QUESTION1
        self.seqNum = 1
        self.lastTime = 0 # the last time LSP was sent
        self.ttl = heartbeatTime # QUESTION2
        self.router_packets = {}

        self.router_packets[addr] = {
            #'nodeID' : self.addr,
            'neighbours' : self.neighbours,
            'seqNum' : self.seqNum,
            #'ttl' : self.ttl
        } 
Beispiel #23
0
 def __init__(self, addr, hearbeatTime):
     """TODO: add your own class fields and initialization code here"""
     Router.__init__(self, addr)  # initialize superclass - don't remove
Beispiel #24
0
 def __init__(self, spool_size=4096):
     Router.__init__(self)
     self.spool_size = spool_size