(self, src=None, event=None, dst=None, **kargs)
return do_graph(gr, **kargs)
Experimental clone attempt of http://sourceforge.net/projects/afterglow
        each datum is reduced as src -> event -> dst and the data are graphed.
        by default we have IP.src -> IP.dport -> IP.dst
Experimental clone attempt of http://sourceforge.net/projects/afterglow
        each datum is reduced as src -> event -> dst and the data are graphed.
        by default we have IP.src -> IP.dport -> IP.dst
Experimental clone attempt of http : // sourceforge . net / projects / afterglow each datum is reduced as src - > event - > dst and the data are graphed . by default we have IP . src - > IP . dport - > IP . dst
def afterglow(self, src=None, event=None, dst=None, **kargs):
        """Experimental clone attempt of http://sourceforge.net/projects/afterglow
        each datum is reduced as src -> event -> dst and the data are graphed.
        by default we have IP.src -> IP.dport -> IP.dst"""
        if src is None:
            src = lambda x: x['IP'].src
        if event is None:
            event = lambda x: x['IP'].dport
        if dst is None:
            dst = lambda x: x['IP'].dst
        sl = {}
        el = {}
        dl = {}
        for i in self.res:
            try:
                s,e,d = src(i),event(i),dst(i)
                if s in sl:
                    n,l = sl[s]
                    n += 1
                    if e not in l:
                        l.append(e)
                    sl[s] = (n,l)
                else:
                    sl[s] = (1,[e])
                if e in el:
                    n,l = el[e]
                    n+=1
                    if d not in l:
                        l.append(d)
                    el[e] = (n,l)
                else:
                    el[e] = (1,[d])
                dl[d] = dl.get(d,0)+1
            except:
                continue

        import math
        def normalize(n):
            return 2+math.log(n)/4.0

        def minmax(x):
            m,M = min(x),max(x)
            if m == M:
                m = 0
            if M == 0:
                M = 1
            return m,M

        mins,maxs = minmax(map(lambda (x,y): x, sl.values()))
        mine,maxe = minmax(map(lambda (x,y): x, el.values()))
        mind,maxd = minmax(dl.values())
    
        gr = 'digraph "afterglow" {\n\tedge [len=2.5];\n'

        gr += "# src nodes\n"
        for s in sl:
            n,l = sl[s]; n = 1+float(n-mins)/(maxs-mins)
            gr += '"src.%s" [label = "%s", shape=box, fillcolor="#FF0000", style=filled, fixedsize=1, height=%.2f,width=%.2f];\n' % (`s`,`s`,n,n)
        gr += "# event nodes\n"
        for e in el:
            n,l = el[e]; n = n = 1+float(n-mine)/(maxe-mine)
            gr += '"evt.%s" [label = "%s", shape=circle, fillcolor="#00FFFF", style=filled, fixedsize=1, height=%.2f, width=%.2f];\n' % (`e`,`e`,n,n)
        for d in dl:
            n = dl[d]; n = n = 1+float(n-mind)/(maxd-mind)
            gr += '"dst.%s" [label = "%s", shape=triangle, fillcolor="#0000ff", style=filled, fixedsize=1, height=%.2f, width=%.2f];\n' % (`d`,`d`,n,n)

        gr += "###\n"
        for s in sl:
            n,l = sl[s]
            for e in l:
                gr += ' "src.%s" -> "evt.%s";\n' % (`s`,`e`) 
        for e in el:
            n,l = el[e]
            for d in l:
                gr += ' "evt.%s" -> "dst.%s";\n' % (`e`,`d`) 
            
        gr += "}"
        return do_graph(gr, **kargs)
def afterglow ( self , src = None , event = None , dst = None , * * kargs ) : if src is None : src = lambda x : x [ 'IP' ] . src if event is None : event = lambda x : x [ 'IP' ] . dport if dst is None : dst = lambda x : x [ 'IP' ] . dst sl = { } el = { } dl = { } for i in self . res : try : s , e , d = src ( i ) , event ( i ) , dst ( i ) if s in sl : n , l = sl [ s ] n += 1 if e not in l : l . append ( e ) sl [ s ] = ( n , l ) else : sl [ s ] = ( 1 , [ e ] ) if e in el : n , l = el [ e ] n += 1 if d not in l : l . append ( d ) el [ e ] = ( n , l ) else : el [ e ] = ( 1 , [ d ] ) dl [ d ] = dl . get ( d , 0 ) + 1 except : continue import math def normalize ( n ) : return 2 + math . log ( n ) / 4.0 def minmax ( x ) : m , M = min ( x ) , max ( x ) if m == M : m = 0 if M == 0 : M = 1 return m , M mins , maxs = minmax ( map ( lambda ( x , y ) : x , sl . values ( ) ) ) mine , maxe = minmax ( map ( lambda ( x , y ) : x , el . values ( ) ) ) mind , maxd = minmax ( dl . values ( ) ) gr = 'digraph "afterglow" {\n\tedge [len=2.5];\n' gr += "# src nodes\n" for s in sl : n , l = sl [ s ] n = 1 + float ( n - mins ) / ( maxs - mins ) gr += '"src.%s" [label = "%s", shape=box, fillcolor="#FF0000", style=filled, fixedsize=1, height=%.2f,width=%.2f];\n' % ( `s` , `s` , n , n ) gr += "# event nodes\n" for e in el : n , l = el [ e ] n = n = 1 + float ( n - mine ) / ( maxe - mine ) gr += '"evt.%s" [label = "%s", shape=circle, fillcolor="#00FFFF", style=filled, fixedsize=1, height=%.2f, width=%.2f];\n' % ( `e` , `e` , n , n ) for d in dl : n = dl [ d ] n = n = 1 + float ( n - mind ) / ( maxd - mind ) gr += '"dst.%s" [label = "%s", shape=triangle, fillcolor="#0000ff", style=filled, fixedsize=1, height=%.2f, width=%.2f];\n' % ( `d` , `d` , n , n ) gr += "###\n" for s in sl : n , l = sl [ s ] for e in l : gr += ' "src.%s" -> "evt.%s";\n' % ( `s` , `e` ) for e in el : n , l = el [ e ] for d in l : gr += ' "evt.%s" -> "dst.%s";\n' % ( `e` , `d` ) gr += "}" return do_graph ( gr , * * kargs )