def parse(self):
        ''' Check MGEN receiver's log file for packet sequence numbers, and
            return the percentage of lost packets.
        '''
        logfile = os.path.join(self.node.nodedir, 'var.log/mgen.log')
        f = open(logfile, 'r')
        numlost = 0
        lastseq = 0
        for line in f.readlines():
            fields = line.split()
            if fields[1] != 'RECV':
                continue
            try:
                seq = int(fields[4].split('>')[1])
            except:
                self.info("Unexpected MGEN line:\n%s" % fields)
            if seq > (lastseq + 1):
                numlost += seq - (lastseq + 1)
            lastseq = seq
        f.close()
        if lastseq > 0:
            loss = 100.0 * numlost / lastseq
        else:
            loss = 0
        if self.verbose:
            self.info("Receiver log shows %d of %d packets lost" % \
                      (numlost, lastseq))
        return loss
dataset/ETHPy150Open coreemu/core/daemon/examples/netns/wlanemanetests.py/MgenCmd.parse/original