File: nstonam.awk

package info (click to toggle)
ns2 2.35%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 78,120 kB
  • sloc: cpp: 172,923; tcl: 107,127; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 812; awk: 525; csh: 355
file content (57 lines) | stat: -rw-r--r-- 1,137 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/awk

#
# nam fmt:
#	eventCode time src dst size attr type conv id
#
# ns fmt:
#	eventCode time src dst pktType size flags class src.sport dst.dport
#		seqno uid
#

$2 ~ /testName/ {
  next;
}
$1 ~ /v/ {
  print $0;
  next;
}
$1 ~ /[dh+-]/ {
	print $1, $2, $3, $4, $6, $8, $5, $8, $12
	if ($1 == "h") {
		group = int($10) % 256;
		if ($3 < $4)
			key = $3 $4;
		else
			key = $4 $3;

		if (subscription[key] < group) {
			subscription[key] = group;
			print "v " $2 " $theNet ecolor " $3 " " $4 " $colorMap(" group ")"
			print "v " $2 " $theNet ecolor " $4 " " $3 " $colorMap(" group ")"
		}
	}
	if ($5 == "prune") {
		group = int($10) % 256;
		if ($3 < $4)
			key = $3 $4;
		else
			key = $4 $3;

		if (subscription[key] == group) {
			group -= 1;
			subscription[key] = group;
			print "v " $2 " $theNet ecolor " $3 " " $4 " $colorMap(" group ")"
			print "v " $2 " $theNet ecolor " $4 " " $3 " $colorMap(" group ")"
		}
	}
	#
	# print a hop event for each deque
	# (ns-2 doesn't dump hop events by default since
	# we can infer them from the "-" event)
	#
	if ($1 == "-")
		print "h", $2, $3, $4, $6, $8, $5, $8, $12
		
}