def getBwDifferential(self): self.iat_length_tuples = [l for l in self.iat_length_tuples if len(l) > 0] if time.time() - self.session.startTime > 0.2 and len(self.iat_length_tuples) > 1: lengths0 = [t[1] for t in self.iat_length_tuples[-2]] lengths1 = [t[1] for t in self.iat_length_tuples[-1]] bw0 = sum(lengths0) / self._period bw1 = sum(lengths1) / self._period bw_diff = (bw1 - bw0) / self._period self.session.bw_diffs.append(bw_diff) log.debug("[bwdiff %s] - bw diffs: %s", self.end, self.session.bw_diffs) log.debug("[bwdiff %s] - abs bwdiff (%s) > threshold (%s)", self.end, abs(bw_diff), self._threshold) if abs(bw_diff) > self._threshold: # we should sample uniformly from the passed iats # convert self.iat_length_tuples to distribution # and pass it to wfpad iat distribution as dict. iats = gu.get_iats([t[0] for t in gu.flatten_list(self.iat_length_tuples)]) h = {iat: 1 for iat in iats} self._burstHistoProbdist['snd'] = hs.new(h) self._gapHistoProbdist['snd'] = hs.new(h) else: self._burstHistoProbdist['snd'] = hs.uniform(const.INF_LABEL) self._gapHistoProbdist['snd'] = hs.uniform(const.INF_LABEL) self.iat_length_tuples.append([]) log.debug("[bwdiff %s] A period has passed: %s", self.end, self.iat_length_tuples[-3:-1]) if self.isVisiting(): log.debug("[bwdiff %s] Calling next period (visiting = %s, padding = %s)", self.end, self.isVisiting(), self.session.is_padding) cm.deferLater(self._period, self.getBwDifferential)
def getAverageTs(self): avg_ts = mu.median( gu.get_iats( [t[0] for t in gu.flatten_list(self.iat_length_tuples)])) log.debug("[bwdiff - %s] Average ts in the session is: %s.", self.end, avg_ts) return avg_ts
def getBwDifferential(self): self.iat_length_tuples = [ l for l in self.iat_length_tuples if len(l) > 0 ] if time.time() - self.session.startTime > 0.2 and len( self.iat_length_tuples) > 1: lengths0 = [t[1] for t in self.iat_length_tuples[-2]] lengths1 = [t[1] for t in self.iat_length_tuples[-1]] bw0 = sum(lengths0) / self._period bw1 = sum(lengths1) / self._period bw_diff = (bw1 - bw0) / self._period self.session.bw_diffs.append(bw_diff) log.debug("[bwdiff %s] - bw diffs: %s", self.end, self.session.bw_diffs) log.debug("[bwdiff %s] - abs bwdiff (%s) > threshold (%s)", self.end, abs(bw_diff), self._threshold) if abs(bw_diff) > self._threshold: # we should sample uniformly from the passed iats # convert self.iat_length_tuples to distribution # and pass it to wfpad iat distribution as dict. iats = gu.get_iats( [t[0] for t in gu.flatten_list(self.iat_length_tuples)]) h = {iat: 1 for iat in iats} self._burstHistoProbdist['snd'] = hs.new(h) self._gapHistoProbdist['snd'] = hs.new(h) else: self._burstHistoProbdist['snd'] = hs.uniform(const.INF_LABEL) self._gapHistoProbdist['snd'] = hs.uniform(const.INF_LABEL) self.iat_length_tuples.append([]) log.debug("[bwdiff %s] A period has passed: %s", self.end, self.iat_length_tuples[-3:-1]) if self.isVisiting(): log.debug( "[bwdiff %s] Calling next period (visiting = %s, padding = %s)", self.end, self.isVisiting(), self.session.is_padding) cm.deferLater(self._period, self.getBwDifferential)
def getAverageTs(self): avg_ts = mu.median(gu.get_iats([t[0] for t in gu.flatten_list(self.iat_length_tuples)])) log.debug("[bwdiff - %s] Average ts in the session is: %s.", self.end, avg_ts) return avg_ts