From 944720a29e4060623b0a3cd6c97ea24c30f82f5d Mon Sep 17 00:00:00 2001 From: Raphael Bauduin Date: Tue, 2 Jun 2015 16:41:25 -0700 Subject: [PATCH] identify blocks by sequence numbers, not very good --- src/mpBurstBlocks.py | 49 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/mpBurstBlocks.py b/src/mpBurstBlocks.py index d0bd49b..7a98c0f 100644 --- a/src/mpBurstBlocks.py +++ b/src/mpBurstBlocks.py @@ -25,30 +25,57 @@ class BurstBlocksAggregator: def c(self,column): """Return column index corresponding to name passed as argument""" return self.headers.index(column) +# def extract_blocks(self): +# # beginning of block. First block starts at packet 0 +# b=0 +# # iteration, we can start at packet 1 +# i=1 +# previous=0 +# while i>self.log, "previous seq packet:", "{:10.8f}".format(self.a[previous][self.c("ts")]), "seq:", self.a[previous][self.c("map_begin")] +# print >>self.log, "found block starting at ", "{:10.8f}".format(self.a[i][self.c("ts")]), "seq:", self.a[i][self.c("map_begin")] +# # we know the start of the block and look for its last packet +# elif self.a[i][self.c("ts")]-self.a[previous][self.c("ts")]>self.min_block_sep: +# print >>self.log, "next block:", "{:10.8f}".format(self.a[i+1][self.c("ts")]), "seq:", self.a[i+1][self.c("map_begin")] +# print >>self.log,"--------------------------------------" +# # the ranges we use here are inclusive, ie the range contains both elements. +# self.blocks.append((b,previous)) +# b=i +# # keep track of previous seq packet +# previous=i +# i=i+1 +# self.blocks.append((b,previous)) +# print >>self.log, "# blocks: ", len(self.blocks) +# detect blocks based on number of bytes sent def extract_blocks(self): # beginning of block. First block starts at packet 0 b=0 # iteration, we can start at packet 1 i=1 - previous=0 + last_end=None while i>self.log, "previous seq packet:", "{:10.8f}".format(self.a[previous][self.c("ts")]), "seq:", self.a[previous][self.c("map_begin")] - print >>self.log, "found block starting at ", "{:10.8f}".format(self.a[i][self.c("ts")]), "seq:", self.a[i][self.c("map_begin")] + if b==None and last_end!=None: + if self.a[i][self.c("map_begin")]==self.a[last_end][self.c("map_end")]: + b=i + print >>self.log, "found block starting at ", "{:10.8f}".format(self.a[i][self.c("ts")]), "seq:", self.a[i][self.c("map_begin")] # we know the start of the block and look for its last packet - elif self.a[i][self.c("ts")]-self.a[previous][self.c("ts")]>self.min_block_sep: - print >>self.log, "next block:", "{:10.8f}".format(self.a[i+1][self.c("ts")]), "seq:", self.a[i+1][self.c("map_begin")] + elif self.a[i][self.c("map_end")]-self.a[b][self.c("map_begin")]==65536: + print >>self.log, "found block ending at ", "{:10.8f}".format(self.a[i][self.c("ts")]), "end seq:", self.a[i][self.c("map_end")] print >>self.log,"--------------------------------------" # the ranges we use here are inclusive, ie the range contains both elements. - self.blocks.append((b,previous)) - b=i + self.blocks.append((b,i)) + last_end = i + b=None + print self.blocks # keep track of previous seq packet - previous=i i=i+1 - self.blocks.append((b,previous)) + self.blocks.append((b,i-1)) print >>self.log, "# blocks: ", len(self.blocks) def extract_times(self): for i in range(len(self.blocks)):