NS2网络模拟(1)-延迟
1: #NS2_有线部分\EndDelay.awk
2:
3: BEGIN {
4: #Initialize the variable
5: MaxID = 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: #Record the maxmum
47: if (PKTID > MaxID)
48: MaxID = PKTID;
49:
50: #Record the transmitter time
51: if (StartTime[PKTID] == 0)
52: StartTime[PKTID] = TIME;
53:
54:
55: if (EVENT == "r" && FLOWID == 1)
56: {
57: # printf("after: %s\t%d\t%s\n", EVENT, FLOWID, TIME);
58: EndTime[PKTID] = TIME;
59: # printf("%g %d %d %s %d %s %d %d.%d %d.%d %d %d\n", EVENT, TIME, FLOWID, PKTID);
60: # printf("after: %s %d %s %d\n", EVENT, FLOWID, EndTime[PKTID], PKTID);
61: # if (EVENT == "r")
62: # {
63: # EndTime[PKTID] = TIME;
64: # }
65:
66: }
67: else
68: {
69: EndTime[PKTID] = -1;
70:
71: }
72:
73:
74: }
75:
76: END {
77: for (PKTID = 0; PKTID <= MaxID; PKTID ++)
78: {
79: Start = StartTime[PKTID];
80: End = EndTime[PKTID];
81: Delay = End - Start;
82: if (Delay >= 0)
83: printf("%f\t%f\n", Start, Delay);
84: # packet_duration = EndTime[PKTID] - StartTime[PKTID];
85:
86: # printf("%f\t%f\n", start, packet_duration);
87: }
88: }
89:
本文来自博客园,作者:方倍工作室,转载请注明原文链接:https://www.cnblogs.com/txw1958/archive/2011/10/13/2210115.html