📄 np_obtree.py
字号:
+ int((blank[0] - conn.gap_before)*scalef) \ + (blank[1] + conn.ngaps_before)*self.gapwidth + 1 LINE(blankx, y, blankx+self.gapwidth-1, y, fill="white", width=2) # draw in the packet arrivals sfin_seen = 0 cfin_seen = 0 ssyn_seen = 0 csyn_seen = 0 pl = conn.pktlist[:] pl.reverse() for pkt in pl: #way = ord(pkt.way[0]) way = pkt.dir #flags = ord(pkt.flags[0]) flags = pkt.flags pkt.pktx = x = self.leftmargin \ + int((pkt.tm - pkt.pkt_gap_before)*scalef) \ + pkt.pkt_ngaps_before*self.gapwidth if flags & (TH_SYN | TH_RST | TH_FIN): wi = 2 ht = 6 col = 'blue' if flags & TH_SYN: if way == SERVER: if ssyn_seen: col = '#00d7ff' ssyn_seen = 1 else: if csyn_seen: col = '#00d7ff' csyn_seen = 1 elif flags & TH_FIN: if way == SERVER: if sfin_seen: col = '#00d7ff' sfin_seen = 1 else: if cfin_seen: col = '#00d7ff' cfin_seen = 1 elif flags & TH_RST: col = 'red' else: wi = 1 ht = 3 col = 'black' if way == SERVER: if pkt.tm == conn.cliacksyn: col = 'green' yp = y+ht else: if pkt.tm == conn.servacksyn: col = 'green' yp = y-ht if not dist: col = 'grey72' LINE(x, y, x, yp, fill=col, width=wi) self.label_conn(canv, conn, labelfront, xopen, xclose, y, dist)############################################################################# def draw_conns_v(self): tconns = self.client.connlist canv = self.view scalef = canv.scalef LINE = canv.create_line topy = self.view.topy if len(self.client.implied_obs): topy = topy+self.impobjht if self.pktdict: pd = 0 else: pd = 1 pktdict = self.pktdict #print 'drawing conns_v:' for conn in tconns: # in distinguished tree? if self.rooturl and not (conn in self.tree_conns): dist = 0 else: dist = 1 optm = conn.open clotm = conn.close dur = conn.dur if dist: colour = "blue" else: colour = 'grey72' y = conn.vy = topy + conn.indx*self.vconnht + self.vconnht/2 x0 = conn.xv0 = self.leftmargin + int(optm*scalef) x1 = conn.xv1 = x0 + int(dur*scalef) #print '(%d-%d, %d)' % (x0, x1, y) if conn.ns_attached: labelfront = self.draw_lookup_v(conn.lookup, y) - 8 else: labelfront = x0 - 8 conn.vhandle = LINE(x0, y, x1, y, fill=colour, width=2) # don't know if maxvx set yet try: maxvx = conn.maxvx except AttributeError: maxvx = 0 conn.maxvx = max(maxvx, x1) # draw in the packet arrivals sfin_seen = 0 cfin_seen = 0 ssyn_seen = 0 csyn_seen = 01 pl = conn.pktlist[:] pl.reverse() for pkt in pl: #way = ord(pkt.way[0]) way = pkt.dir #flags = ord(pkt.flags[0]) flags = pkt.flags pkt.pktvx = x = self.leftmargin + int(pkt.tm*scalef) if flags & (TH_SYN | TH_RST | TH_FIN): wi = 2 ht = 6 col = 'blue' if flags & TH_SYN: if way == SERVER: if ssyn_seen: col = '#00d7ff' ssyn_seen = 1 else: if csyn_seen: col = '#00d7ff' csyn_seen = 1 elif flags & TH_FIN: if way == SERVER: if sfin_seen: col = '#00d7ff' sfin_seen = 1 else: if cfin_seen: col = '#00d7ff' cfin_seen = 1 elif flags & TH_RST: col = 'red' else: wi = 1 ht = 3 col = 'black' if way == SERVER: if pkt.tm == conn.cliacksyn: col = 'green' yp = y+ht else: if pkt.tm == conn.servacksyn: col = 'green' yp = y-ht if not dist: col = 'grey72' LINE(x, y, x, yp, fill=col, width=wi) # draw in the packet arrivals for pkt in conn.pktlist: #pkt.printself_rel() #flags = ord(pkt.flags[0]) flags = pkt.flags pkt.pktvx = x = self.leftmargin + int(pkt.tm*scalef) if (flags & TH_SYN) or (flags & TH_RST) or (flags & TH_FIN): continue #way = ord(pkt.way[0]) way = pkt.dir if way == SERVER: if pkt.tm == conn.servacksyn: continue yp = y+3 else: if pkt.tm == conn.cliacksyn: continue yp = y-3 if dist: col = 'black' else: col = 'grey72' LINE(x, y, x, yp, fill=col, width = 1) if dist: self.label_conn(canv, conn, labelfront, x0, x1, y, dist)############################################################################# def draw_lookup(self, lookup, y): canv = self.draw LINE = canv.create_line scalef = canv.scalef #print 'drawing lookup' reqtm = lookup.reqtm reptm = lookup.reptm dur = lookup.dur totgap = 0 ngaps = 0 gap_blanks = [] for gap in lookup.gaps: gap_blanks.append((gap[0] - totgap, ngaps)) totgap = totgap + gap[1] ngaps = ngaps + 1## print '#%d %9d-%9d %9d %9d %3d' % (conn.id, optm/1000,## clotm/1000, dur/1000, ## conn.gap_before, conn.ngaps_before), colour = "red" x0 = self.leftmargin \ + int((reqtm - lookup.gap_before)*scalef) \ + lookup.ngaps_before*self.gapwidth x1 = x0 + int((dur - totgap)*scalef) + ngaps*self.gapwidth #print '(%d-%d)' % (x0, x1) LINE(x0, y, x1, y, fill=colour, width=2) LINE(x0, y+4, x0, y-4, fill=colour, width=2) LINE(x1, y+4, x1, y-4, fill=colour, width=2) # blank out the gaps for blank in gap_blanks: blankx = self.leftmargin \ + int((blank[0] - lookup.gap_before)*scalef) \ + (blank[1] + lookup.ngaps_before)*self.gapwidth + 1 LINE(blankx, y, blankx+self.gapwidth-1, y, fill="white", width=2) self.label_lookup(canv, lookup, x0, x1, y) return x0############################################################################# def draw_lookup_v(self, lookup, y): canv = self.view LINE = canv.create_line scalef = canv.scalef #print 'drawing lookup_v:' reqtm = lookup.reqtm reptm = lookup.reptm dur = lookup.dur colour = "red" x0 = self.leftmargin \ + int(reqtm*scalef) x1 = x0 + int(dur*scalef) #print '(%d-%d)' % (x0, x1) LINE(x0, y, x1, y, fill=colour, width=2) LINE(x0, y+4, x0, y-4, fill=colour, width=2) LINE(x1, y+4, x1, y-4, fill=colour, width=2) self.label_lookup(canv, lookup, x0, x1, y) return x0############################################################################# def draw_reqs(self): reqs = self.client.translist canv = self.draw scalef = canv.scalef LINE = canv.create_line RECT = canv.create_rectangle topy = self.draw.topy if len(self.client.implied_obs): #topy = topy+self.impobjht topy = topy+self.connht #print 'drawing %d reqs:' % (len(reqs)) for req in reqs: # part of distinguished tree? if self.rooturl and not (req in self.tree_trans): dist = 0 else: dist = 1 ycentre = req.y = topy +req.TConn.indx*self.connht + self.conncentre y0 = req.y0 = ycentre - self.reqht/2 y1 = req.y1 = req.y0 + self.reqht if req.cvalid: reqstart = req.reqstart reqend = req.reqend cobtype = req.cobtype if dist: ccolour = self.tdict[cobtype][1] else: ccolour = 'grey72' #draw the request xreqstart = req.xreqstart = self.leftmargin \ + int((reqstart - req.reqstart_gap_before)*scalef) \ + req.reqstart_ngaps_before*self.gapwidth if reqend != reqstart: xreqend = req.xreqend = self.leftmargin \ + int((reqend - req.reqend_gap_before)*scalef) \ + req.reqend_ngaps_before*self.gapwidth else: xreqend = req.xreqend = xreqstart RECT(xreqstart, y0, xreqend, ycentre, fill=ccolour, outline=ccolour, width=2) else: xreqstart = xreqend = 0 if req.svalid: repstart = req.repstart repend = req.repend sobtype = req.sobtype if dist: scolour = self.tdict[sobtype][1] else: scolour = 'grey72' #draw the response xrepstart = req.xrepstart = self.leftmargin \ + int((repstart - req.repstart_gap_before)*scalef) \ + req.repstart_ngaps_before*self.gapwidth if repend != repstart: xrepend = req.xrepend = self.leftmargin \ + int((repend - req.repend_gap_before)*scalef) \ + req.repend_ngaps_before*self.gapwidth else: xrepend = req.xrepend = xrepstart RECT(xrepstart, ycentre, xrepend, y1, fill=scolour, outline=scolour, width=2) repdel = req.delrepend - req.repend ## if repdel:## xdelrepend = self.leftmargin \## + int((req.TConn.servfin - req.TConn.sfin_gap_before)*scalef) \## + req.TConn.sfin_ngaps_before*self.gapwidth## RECT(xrepend, ycentre, xdelrepend, y1, ## outline=scolour, width=1) else: # no response drawn - point it all at the request xrepstart = xrepend = req.xrepstart = req.xrepend = xreqend # blank out the gaps totgap = 0 ngaps = 0 gap_blanks = [] for gap in req.gaps: gap_blanks.append((gap[0] - totgap, ngaps)) totgap = totgap + gap[1] ngaps = ngaps + 1 for blank in gap_blanks: blankx = self.leftmargin \ + int((blank[0] - req.gap_before)*scalef) \ + (blank[1] + req.ngaps_before)*self.gapwidth + 1 RECT(blankx, y0-1, blankx+self.gapwidth-2, y1+1, fill="white", outline="") self.label_req(canv, req, xreqstart, xreqend, xrepstart, xrepend, y0, ycentre, y1, dist)############################################################################# def draw_reqs_v(self): reqs = self.client.translist canv = self.view scalef = canv.scalef canv.leftmargin = self.leftmargin LINE = canv.create_line RECT = canv.create_rectangle topy = self.view.topy if len(self.client.implied_obs): topy = topy+self.impobjht #print 'drawing reqs_v:' for req in reqs: # part of distinguished tree? if self.rooturl and not (req in self.tree_trans): dist = 0 else: dist = 1 ycentre = req.yv = topy +req.TConn.indx*self.vconnht + self.vconncentre y0 = req.yv0 = ycentre - self.reqht/2 y1 = req.yv1 = y0 + self.reqht if req.cvalid: reqstart = req.reqstart reqend = req.reqend reqdur = req.reqdur cobtype = req.cobtype if dist:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -