Exemplo n.º 1
0
def plotter(protocolname, varName, srcNode):
    total = 0.0
    dropped = 0.0
    for i in range(0, RUNNUM):
        list1 = []
        list2 = []
        nstrace.nsopen(protocolname + "/" + protocolname + str(i) + ".tr")
        while not nstrace.isEOF():
            if nstrace.isVar():
                (time, src_node, dummy, dummy, dummy, name,
                 val) = nstrace.getVar()
                if time > TIMELIMIT:
                    break
                if name == varName and src_node == srcNode:
                    list1.append(time)
                    list2.append(val * (100 if varName == "rtt_" else 1))
            elif varName == "loss":
                (event, time, dummy, dummy, dummy, dummy, dummy, dummy,
                 src_node, dummy, dummy, dummy) = nstrace.getEvent()
                if time > TIMELIMIT:
                    break
                if src_node[0] == srcNode and event == 'd':
                    dropped += 1
                    list1.append(time)
                    list2.append(1)
            else:
                nstrace.skipline()
        ll1.append(list1)
        ll2.append(list2)
def only_vars(file_name, v_name):
    ts = []
    vs = []
    nstrace.nsopen(file_name)
    while not nstrace.isEOF():
        if nstrace.isVar():
            (time, src_node, src_flow, dst_node, dst_flow, var_name, var_value)=\
                nstrace.getVar()
            if v_name == var_name:
                ts.append(time)
                vs.append(var_value)
        else:
            nstrace.skipline()
    return ts, vs
Exemplo n.º 3
0
def only_vars(file_name, v_name):
    t1 = []
    v1 = []

    t2 = []
    v2 = []

    nstrace.nsopen(file_name)
    while not nstrace.isEOF():
        if nstrace.isVar():
            (time, src_node, src_flow, dst_node, dst_flow, var_name, var_value)=\
                nstrace.getVar()
            if v_name == var_name:
                if src_node == 0:
                    t1.append(time)
                    v1.append(var_value)
                elif src_node == 1:
                    t2.append(time)
                    v2.append(var_value)
        else:
            nstrace.skipline()
    nstrace.nsclose()
    return t1, v1, t2, v2
def dup_counter(filename):
   SEND_NODE = 1
   DEST_NODE = 2
   FLOW = 0
   count = 0
   thro=0
   COUNTS = {}
   INSTR = []
   nstrace.nsopen(filename)
   for x in xrange(1000):
       INSTR.append(0)

   while not nstrace.isEOF():
       if nstrace.isEvent():
           (event, time, sendnode, dest, packetname, size, dummy, flow, dummy, dummy, seqno, dummy) = nstrace.getEvent()
           #if (event == "r" and dest == DEST_NODE and size >= 1000 and flow == FLOW):
           #print dest, "= dest"
           if (event == "r" and packetname=="tcp" and dest ==DEST_NODE):
               
               if (seqno in COUNTS):
                   nstrace.skipline()
               else:
                   COUNTS[seqno] = 1
                   thro = thro + size
                   
                   for x in xrange(0,51):
                       for y in xrange(0,10):
                            if( time>float(x)+(float(y)/10.0) and time <= float(x)+(float(y+1)/10.0) ):
                                INSTR[(x*10)+y]= INSTR[(x*10)+y]+size
                                
       else:
           nstrace.skipline()
   print "Throughput is", thro
   for x in xrange(0,51):
       for y in xrange(0,10):
           print "\n ",count," Inst throughput between time  ", float(x)+(float(y)/10.0) , "and" , float(x)+(float(y+1)/10.0),"=", INSTR[(x*10)+y]        
           count+=1