Example #1
0
    def delete(self, ip, remove_from_iptable=True):
        """Deletes an entry from the ip_table"""

        logging.info("Deleting neighbour %s", ip_to_str(ip))

        if remove_from_iptable:
            del self.ip_table[ip]

        # close the connection ( if any )
        if self.ntk_client[ip].connected:
            self.ntk_client[ip].close()

        # delete the entry from the translation table...
        old_id = self.translation_table.pop(ip)
        # ...and from the netid_table
        old_netid = self.netid_table.pop(ip)
        # send a message notifying we deleted the entry
        self.events.send('NEIGH_DELETED', (Neigh(bestdev=None,
                                                 devs=None,
                                                 idn=old_id,
                                                 ip=ip,
                                                 netid=old_netid,
                                                 ntkd=self.ntk_client[ip]), ))

        del self.ntk_client[ip]
Example #2
0
    def delete(self, ip, remove_from_iptable=True):
        """Deletes an entry from the ip_table"""

        logging.info("Deleting neighbour %s", ip_to_str(ip))

        if remove_from_iptable:
            del self.ip_table[ip]

        # close the connection ( if any )
        if self.ntk_client[ip].connected:
            self.ntk_client[ip].close()

        # delete the entry from the translation table...
        old_id = self.translation_table.pop(ip)
        # ...and from the netid_table
        old_netid = self.netid_table.pop(ip)
        # send a message notifying we deleted the entry
        self.events.send('NEIGH_DELETED',
                         (Neigh(bestdev=None,
                                devs=None,
                                idn=old_id,
                                ip=ip,
                                netid=old_netid,
                                ntkd=self.ntk_client[ip]),))

        del self.ntk_client[ip]
Example #3
0
    def ip_change(self, oldip, newip):
        """Adds `newip' in the Neighbours as a copy of `oldip', then it removes
        `oldip'. The relative events are raised."""

        logging.info("New IP of neighbour %s is now %s " %
                     (ip_to_str(oldip), ip_to_str(newip)))
        self.ip_table[newip] = self.ip_table[oldip]
        self.translation_table[newip] = self.translation_table[oldip]
        self.netid_table[newip] = self.netid_table[oldip]

        # we have to create a new TCP connection
        self.ntk_client[newip] = rpc.TCPClient(ip_to_str(newip))

        self.events.send('NEIGH_NEW',
                         (Neigh(bestdev=self.ip_table[newip].bestdev,
                                devs=self.ip_table[newip].devs,
                                idn=self.translation_table[newip],
                                ip=newip,
                                netid=self.netid_table[newip],
                                ntkd=self.ntk_client[newip]), ))

        self.delete(oldip)
Example #4
0
    def ip_change(self, oldip, newip):
        """Adds `newip' in the Neighbours as a copy of `oldip', then it removes
        `oldip'. The relative events are raised."""

        logging.info("New IP of neighbour %s is now %s " % (ip_to_str(oldip),
                                                            ip_to_str(newip)))
        self.ip_table[newip] = self.ip_table[oldip]
        self.translation_table[newip] = self.translation_table[oldip]
        self.netid_table[newip] = self.netid_table[oldip]

        # we have to create a new TCP connection
        self.ntk_client[newip] = rpc.TCPClient(ip_to_str(newip))

        self.events.send('NEIGH_NEW',
                         (Neigh(bestdev=self.ip_table[newip].bestdev,
                                devs=self.ip_table[newip].devs,
                                idn=self.translation_table[newip],
                                ip=newip,
                                netid=self.netid_table[newip],
                                ntkd=self.ntk_client[newip]),))

        self.delete(oldip)
Example #5
0
    def time_register(self, _rpc_caller, radar_id, netid):
        """save each node's rtt"""

        if radar_id != self.radar_id:
            # drop. It isn't a reply to our current bouquet
            return

        ip = str_to_ip(_rpc_caller.ip)
        net_device = _rpc_caller.dev

        # this is the rtt
        time_elapsed = int((self.xtime.time() - self.bcast_send_time) / 2)
        # let's store it in the bcast_arrival_time table
        if ip in self.bcast_arrival_time:
            if net_device in self.bcast_arrival_time[ip]:
                self.bcast_arrival_time[ip][net_device].append(time_elapsed)
            else:
                self.bcast_arrival_time[ip][net_device] = [time_elapsed]
        else:
            self.bcast_arrival_time[ip] = {}
            self.bcast_arrival_time[ip][net_device] = [time_elapsed]
            logging.info("Radar: new IP %s detected", ip_to_str(ip))

        self.neigh.netid_table[ip] = netid
Example #6
0
    def time_register(self, _rpc_caller, radar_id, netid):
        """save each node's rtt"""

        if radar_id != self.radar_id:
            # drop. It isn't a reply to our current bouquet
            return

        ip = str_to_ip(_rpc_caller.ip)
        net_device = _rpc_caller.dev

        # this is the rtt
        time_elapsed = int((self.xtime.time() - self.bcast_send_time) / 2)
        # let's store it in the bcast_arrival_time table
        if ip in self.bcast_arrival_time:
            if net_device in self.bcast_arrival_time[ip]:
                self.bcast_arrival_time[ip][net_device].append(time_elapsed)
            else:
                self.bcast_arrival_time[ip][net_device] = [time_elapsed]
        else:
            self.bcast_arrival_time[ip] = {}
            self.bcast_arrival_time[ip][net_device] = [time_elapsed]
            logging.info("Radar: new IP %s detected", ip_to_str(ip))

        self.neigh.netid_table[ip] = netid