#! /usr/local/bin/perl open(infile,$ARGV[0]) || die("Can't open input file\n"); $if=$ARGV[1]; # requested interface $maxt=-9e99; $mint= 9e99; $maxu=-9e99; $minu= 9e99; # skip header while(read(infile,$record,512)){ $cellcount=vec($record,2,8)*256+vec($record,3,8); $interface=vec($record,4,8)*256+vec($record,5,8); printf stderr "$interface\t$cellcount\n"; # Start reading in entries for ($i = 1; $i <= 17408; $i++) { read(infile,$record,60) || exit; if($i > $cellcount){next;} if(($if > 0) && ($if != $interface)){next;} if(vec($record,18,8) == 0x08){ $ts1= vec($record,4,8); $ts2= vec($record,5,8); $clock=($ts1<<8)+$ts2; if($clock < $oldclock){$clock2++;} $oldclock=$clock; $timestamp=(($clock2*65536)+$clock)*0.00000004; $src = vec($record,8,32); $dst = vec($record,9,32); $plen = vec($record,22,8)*256+vec($record,23,8); $prot = vec($record,29,8); $ihl = (vec($record,20,8)&0xf)*4; $sport = vec($record,$ihl+20,8)*256+vec($record,$ihl+21,8); $dport = vec($record,$ihl+22,8)*256+vec($record,$ihl+23,8); if(($sport == 53) || ($dport == 53)){ if($prot == 17){ $aru{$plen}++; if($aru{$plen} > $maxvu){$maxvu=$aru{$plen};} if($plen > $maxu){$maxu=$plen;} if($plen < $minu){$minu=$plen;} $tvu++; }elsif($prot == 6){ $art{$plen}++; if($art{$plen} > $maxvt){$maxvt=$art{$plen};} if($plen > $maxt){$maxt=$plen;} if($plen < $mint){$mint=$plen;} $tvt++; } } } } } open(O,">result.udp") || die("Cannot open output file"); foreach $key ( sort numerically ( keys %aru)) { $lvu=$aru{$key}/$maxvu; $accvu=$accvu+($aru{$key}/$tvu); printf O "%d\t%d\t%.6f\t%.6e\t%.6e\t%.4f\n", $key,$aru{$key},$lvu,$accvu,$aru{$key}/$tvu,($key-$minu)/($maxu-$minu); } open(O,">result.tcp") || die("Cannot open output file"); foreach $key ( sort numerically ( keys %art)) { $lvt=$art{$key}/$maxvt; $accvt=$accvt+($art{$key}/$tvt); printf O "%d\t%d\t%.6f\t%.6e\t%.6e\t%.4f\n", $key,$art{$key},$lvt,$accvt,$art{$key}/$tvt,($key-$mint)/($maxt-$mint); } sub numerically { $a <=> $b;}