예제 #1
0
파일: statistics.py 프로젝트: krman/thesis
    def _handle_FlowStatsReceived(self, event):
        stats = flow_stats_to_list(event.stats)
        log.info("GOT STATS")
        #log.info(stats)
        switch = event.dpid
        local = [e for e in self.flows if e.switch == switch]
        
        for flow in stats:
            f = lib.match_to_flow(flow['match'])
            #log.info("{0} became {1}".format(flow,f))
            if not f:
                continue

            try:
                entry = next(e for e in local if e.flow == f)
                log.info("just getting old entry for {0}".format(f))
            except StopIteration:
                log.info("making a new entry for {0}".format(f))
                entry = lib.Entry(switch, f)
                self.flows.append(entry)

            bc = int(flow['byte_count'])
            log.info("old total: {0}, new total: {1}, diff: {2}, recent: {3}".format(entry.total, bc, bc-entry.total, (bc-entry.total)/self.period))
            entry.recent = (bc - entry.total) / self.period
            entry.total = bc
예제 #2
0
파일: statistics.py 프로젝트: krman/thesis
    def _handle_FlowStatsReceived(self, event):
        """
        Handle OFPT_STATS_REPLY messages from switches.
        Add a new entry if flow is previously unseen, else update the old.
        """
        stats = flow_stats_to_list(event.stats)
        switch = event.dpid
        local = [e for e in self.flows if e.switch == switch]
        log.info("stats on switch {0}".format(switch))
        log.info(stats)
        
        for flow in stats:
            f = lib.match_to_flow(flow['match'])
            if not f:
                continue

            try:
                entry = next(e for e in local if e.flow == f)
            except StopIteration:
                entry = lib.Entry(switch, f)
                self.flows.append(entry)

            bc = int(flow['byte_count']) * 8  # want everything in bits
            entry.recent = (bc - entry.total) / self.period
            entry.total = bc
            if entry.recent <= 20000:
                self.flows.remove(entry)