[951] | 1 | # this program is for UDP single mode |
---|
| 2 | # first it opens the result.txt produced from pint.txt |
---|
| 3 | import re |
---|
| 4 | result = open('result.txt').readlines() |
---|
| 5 | length1 = len(result) |
---|
| 6 | |
---|
| 7 | # in order to make sure everything has space between two words so that |
---|
| 8 | # when splitting a sentence into a row of words, not |
---|
| 9 | # any of them get stuck. |
---|
| 10 | |
---|
| 11 | for i in range(0, length1): |
---|
| 12 | result[i] = result[i].replace('- ', '-') |
---|
| 13 | result[i] = result[i].replace('/ ', '/') |
---|
| 14 | result[i] = result[i].replace('[','[ ') |
---|
| 15 | result[i] = result[i].replace(']',' ]') |
---|
| 16 | result[i] = result[i].replace(':',' :') |
---|
| 17 | result[i] = result[i].replace('(','( ') |
---|
| 18 | result[i] = result[i].replace(')',' )') |
---|
| 19 | for i in range(0, length1): |
---|
| 20 | result[i] = result[i].replace('-', ' ') |
---|
| 21 | result[i] = result[i].replace('/', ' ') |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | result = result[5:length1] |
---|
| 25 | length2 = len(result) |
---|
| 26 | |
---|
| 27 | # in below 2 for loops, i is devided by the total number of output lines(3). |
---|
| 28 | # and the remainders tells the specific line that I would like to save into separate file. |
---|
| 29 | # in repnum.txt, the line that contains jitter,lost,totalpacket,and etc is saved into it as vector of words. |
---|
| 30 | # in portadd.txt, the line that contains port numbers of client and server is saved into it, as a vector words. |
---|
| 31 | # python separates a sentence to each words wih a space between them. |
---|
| 32 | |
---|
| 33 | for i in range(0, length2): |
---|
| 34 | if (i%3) == 0: |
---|
| 35 | f = open('ptmp.txt','a') |
---|
| 36 | f.write(str(result[i])+'\n') |
---|
| 37 | f.close() |
---|
| 38 | |
---|
| 39 | elif (i%3) == 2: |
---|
| 40 | f = open('rtmp.txt','a') |
---|
| 41 | f.write(str(result[i])+ '\n') |
---|
| 42 | f.close() |
---|
| 43 | |
---|
| 44 | a = open('ptmp.txt').readlines() |
---|
| 45 | for i in range(0, len(a)): |
---|
| 46 | portadd = a[i] |
---|
| 47 | q = re.split('\s+', str(portadd)) |
---|
| 48 | for j in range(0, len(q)): |
---|
| 49 | s = open('portadd.txt','a') |
---|
| 50 | s.write(str(q[j])+'\n') |
---|
| 51 | s.close() |
---|
| 52 | |
---|
| 53 | f = open('rtmp.txt').readlines() |
---|
| 54 | for i in range(0, len(f)): |
---|
| 55 | repnum = f[i] |
---|
| 56 | p = re.split('\s+', str(repnum)) |
---|
| 57 | for j in range(0, len(p)): |
---|
| 58 | s = open('repnum.txt','a') |
---|
| 59 | s.write(str(p[j])+'\n') |
---|
| 60 | s.close() |
---|
| 61 | |
---|