File: chanInterference-pre.pl

package info (click to toggle)
ns2 2.35%2Bdfsg-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 78,808 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (50 lines) | stat: -rw-r--r-- 1,088 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
sub usage {
	print STDERR "usage: $0 <source trace file> <output trace file>\n";
	print STDERR "<source trace file> - trace file generated by the base tcl file\n";
	print STDERR "<output trace file> - trace file generated after processing \n";
	exit;
}

#@ARGV[0] - source trace file
#@ARGV[1] - output trace file

if($#ARGV != 1) {
	&usage;
	exit;
}

open (Source, $ARGV[0]) or die "Cannot open $ARGV[0] : $!\n";
open (Destination, ">$ARGV[1]") or die "Cannot open $ARGV[1] : $!\n";

my $enter = 0;

$line = <Source>;
while ($line) {
	if($line =~ /^M/) {
		print Destination $line;
		$enter = 1;
	}
	elsif (($line =~ /SENSING_CARRIER/) && ($enter == 0)){
		print Destination $line;
		$temp = <Source>;
		if ($temp !~ /SENSING_CARRIER/) {
			print Destination $temp;
			$line = <Source>;
			@fields = split ' ', $line;
			$t = @fields[2] + 0.001;
			print Destination $line;
			print Destination 'E -t ', $t , ' BACKING_OFF ', @fields[4] , "\n";
		}
		else {
			print Destination $temp;
		}
	}
	else {
		print Destination $line;
	}
	$line = <Source>;
}

close Source;
close Destination;