コード例 #1
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
    def loadResults(cls, jsonFile):
        """Load results from json file
        :param jsonFile : json format file to load from"""
        ms = json.load(open(jsonFile, 'r'))
        methods = {}

        class Host(object):
            def __init__(self, name):
                self.name = name

        for name, method_data in ms.iteritems():
            methods[name] = {}
            methods[name]['pairs'] = []
            methods[name]['real_steps'] = method_data['real_steps']
            for pairdata in method_data['pairs']:
                s = cls.HostStats(
                    method=name,
                    host=Host(pairdata['host']),
                    target=Host(pairdata['target']),
                    baseline=DelayStats(**pairdata['baseline']),
                    baselineMeasures=[
                        DelayStats(**m) for m in pairdata['baselineMeasures']
                    ],
                    measures=[DelayStats(**m) for m in pairdata['measures']])
                methods[name]['pairs'].append(s)
        info("Loading delay results done\n")
        return methods
コード例 #2
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
 def computeBaseline(self):
     sent = 0
     received = 0
     rttmin = 0
     rttavg = 0
     rttmax = 0
     rttdev = 0
     for measure in self.baselineMeasures:
         sent += measure.sent
         received += measure.received
         rttmin = min(
             rttmin,
             measure.rttmin) if rttmin is not 0 else measure.rttmin
         rttmax = max(rttmax, measure.rttmax)
         rttavg += measure.rttavg
         rttdev += measure.rttdev**2
     rttdev = math.sqrt(rttdev / len(self.baselineMeasures))
     rttavg /= len(self.baselineMeasures)
     self.baseline = DelayStats(sent=sent,
                                received=received,
                                rttmin=rttmin,
                                rttavg=rttavg,
                                rttmax=rttmax,
                                rttdev=rttdev)
コード例 #3
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
 def computeBaseline(self):
     sent = 0
     received = 0
     rttmin = 0
     rttavg = 0
     rttmax = 0
     rttdev = 0
     for measure in self.baselineMeasures:
         sent += measure.sent
         received += measure.received
         rttmin = min(rttmin, measure.rttmin) if rttmin is not 0 else measure.rttmin
         rttmax = max(rttmax, measure.rttmax)
         rttavg += measure.rttavg
         rttdev += measure.rttdev ** 2
     rttdev = math.sqrt(rttdev / len(self.baselineMeasures))
     rttavg /= len(self.baselineMeasures)
     self.baseline = DelayStats(
         sent=sent, received=received, rttmin=rttmin, rttavg=rttavg, rttmax=rttmax, rttdev=rttdev
     )
コード例 #4
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
    class HostStats(object):
        """Storage for delay results"""

        def __init__(self, host, target, method="", baseline=None, measures=None, baselineMeasures=None):
            self.host = host
            self.target = target
            if measures is not None:
                self.measures = measures
            else:
                self.measures = []
            self.baseline = baseline
            self.baselineMeasures = baselineMeasures if baselineMeasures is not None else []
            self.method = method

        def subtrackBaseline(self, ping):
            return DelayStats(
                ping.timestamp,
                ping.step,
                ping.sent,
                ping.received,
                ping.rttmin - self.baseline.rttmin,
                ping.rttavg - self.baseline.rttavg,
                ping.rttmax - self.baseline.rttmax,
                ping.rttdev,
            )

        def computeBaseline(self):
            sent = 0
            received = 0
            rttmin = 0
            rttavg = 0
            rttmax = 0
            rttdev = 0
            for measure in self.baselineMeasures:
                sent += measure.sent
                received += measure.received
                rttmin = min(rttmin, measure.rttmin) if rttmin is not 0 else measure.rttmin
                rttmax = max(rttmax, measure.rttmax)
                rttavg += measure.rttavg
                rttdev += measure.rttdev ** 2
            rttdev = math.sqrt(rttdev / len(self.baselineMeasures))
            rttavg /= len(self.baselineMeasures)
            self.baseline = DelayStats(
                sent=sent, received=received, rttmin=rttmin, rttavg=rttavg, rttmax=rttmax, rttdev=rttdev
            )

        def getPair(self):
            return self.host.name, self.target.name

        def getStrPair(self):
            return "%s,%s" % self.getPair()

        def printAll(self):
            return "\n%s -> %s\nbaseline for %s: \n   %s\nmeasures : \n   %s\n" % (
                self.host.name,
                self.target.name,
                self.method,
                self.baseline.printAll() if self.baseline is not None else "",
                "\n   ".join([m.printAll() for m in self.measures]),
            )

        def toDict(self):
            return {
                "host": self.host.name,
                "target": self.target.name,
                "baseline": self.baseline.toDict(),
                "baselineMeasures": [m.toDict() for m in self.baselineMeasures],
                "measures": [m.toDict() for m in self.measures],
            }
コード例 #5
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
 def subtrackBaseline(self, ping):
     return DelayStats(ping.timestamp, ping.step, ping.sent,
                       ping.received,
                       ping.rttmin - self.baseline.rttmin,
                       ping.rttavg - self.baseline.rttavg,
                       ping.rttmax - self.baseline.rttmax, ping.rttdev)
コード例 #6
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
    class HostStats(object):
        """Storage for delay results"""
        def __init__(self,
                     host,
                     target,
                     method='',
                     baseline=None,
                     measures=None,
                     baselineMeasures=None):
            self.host = host
            self.target = target
            if measures is not None:
                self.measures = measures
            else:
                self.measures = []
            self.baseline = baseline
            self.baselineMeasures = baselineMeasures if baselineMeasures is not None else []
            self.method = method

        def subtrackBaseline(self, ping):
            return DelayStats(ping.timestamp, ping.step, ping.sent,
                              ping.received,
                              ping.rttmin - self.baseline.rttmin,
                              ping.rttavg - self.baseline.rttavg,
                              ping.rttmax - self.baseline.rttmax, ping.rttdev)

        def computeBaseline(self):
            sent = 0
            received = 0
            rttmin = 0
            rttavg = 0
            rttmax = 0
            rttdev = 0
            for measure in self.baselineMeasures:
                sent += measure.sent
                received += measure.received
                rttmin = min(
                    rttmin,
                    measure.rttmin) if rttmin is not 0 else measure.rttmin
                rttmax = max(rttmax, measure.rttmax)
                rttavg += measure.rttavg
                rttdev += measure.rttdev**2
            rttdev = math.sqrt(rttdev / len(self.baselineMeasures))
            rttavg /= len(self.baselineMeasures)
            self.baseline = DelayStats(sent=sent,
                                       received=received,
                                       rttmin=rttmin,
                                       rttavg=rttavg,
                                       rttmax=rttmax,
                                       rttdev=rttdev)

        def getPair(self):
            return self.host.name, self.target.name

        def getStrPair(self):
            return "%s,%s" % self.getPair()

        def printAll(self):
            return "\n%s -> %s\nbaseline for %s: \n   %s\nmeasures : \n   %s\n" % (
                self.host.name, self.target.name, self.method,
                self.baseline.printAll() if self.baseline is not None else '',
                "\n   ".join([m.printAll() for m in self.measures]))

        def toDict(self):
            return {
                'host': self.host.name,
                'target': self.target.name,
                'baseline': self.baseline.toDict(),
                'baselineMeasures':
                [m.toDict() for m in self.baselineMeasures],
                'measures': [m.toDict() for m in self.measures]
            }
コード例 #7
0
ファイル: check.py プロジェクト: wicaksana/mininet-NetProbes
 def subtrackBaseline(self, sample):
     """Remove baseline from sample
     :param sample : sample to correct
     """
     return DelayStats(sample.timestamp, sample.step, sample.sent,
                       sample.received, sample.bw - self.baseline.bw)