1: #NS2_有线部分\Throughput.awk
2:
3: BEGIN {
4: #Initialize the variable
5: init = 0;
6: i = 0;
7: }
8:
9: {
10: #Event Abbreviation Type Value
11: #%g %d %d %s %d %s %d %d.%d %d.%d %d %d
12: #Normal Event
13: #r: Receive
14: #d: Drop
15: #e: Error
16: #+: Enqueue
17: #-: Dequeue
18: #double Time
19: #int (Link-layer) Source Node
20: #int (Link-layer) Destination Node
21: #string Packet Name
22: #int Packet Size
23: #string Flags
24: #int Flow ID
25: #int (Network-layer) Source Address
26: #int Source Port
27: #int (Network-layer) Destination Address
28: #int Destination Port
29: #int Sequence Number
30: #int Unique Packet ID
31:
32: #Evaluate the fields to new viariables
33: EVENT = $1;
34: TIME = $2;
35: SRCNODE = $3
36: DSTNODE = $4;
37: PKTNAME = $5;
38: PKTSIZE = $6;
39: FLAGS = $7;
40: FLOWID = $8;
41: SRCADDPORT = $9;
42: DSTADDPORT = $10;
43: SEQNO = $11;
44: PKTID = $12;
45:
46: #Count up the packets send to DstNode
47: if (EVENT == "-" && SRCNODE == 0 && DSTNODE == 1)
48: {
49: ByteSum[i + 1] = ByteSum[i] + PKTSIZE;
50:
51: # if (init == 0) {
52: # StartTime = Time;
53: # init = 1;
54: # }
55:
56: EndTime[i] = TIME;
57: i = i + 1;
58: }
59: }
60:
61: END {
62: printf("%.2f\t%.2f\n", EndTime[0], 0);
63:
64: #Calcute the throughput
65: for (j = 1; j < i; j ++)
66: {
67: Throught = (ByteSum[j] / (EndTime[j] - EndTime[0])) * 8 / 1000;
68: printf("%.2f\t%.2f\n", EndTime[j], Throught);
69: }
70:
71: printf("%.2f\t%.2f\n", EndTime[i - 1], 0);
72: }
73: