#!/usr/local/bin/perl # Encode IP addresses for fr+ packet trace files. # The output format equals the input format, except that the IP # addresses are encoded and consist of a 16 bit wide encoded network number # field, followed by a 16 bit wide encoded host number field. The # encodinguses conventional D/E, C, B, and A classes. $infile=$ARGV[0]; open(infile,$infile) || die; while(read(infile,$record,44)){ $src=vec($record,5,32); $sid=($src>>28)&0xf; $srcn=$src & 0xf0000000;$srch=$src & 0x0fffffff; if($sid < 0xe) {$srcn=$src & 0xffffff00;$srch=$src & 0x000000ff;} if($sid < 0xc) {$srcn=$src & 0xffff0000;$srch=$src & 0x0000ffff;} if($sid < 0x8) {$srcn=$src & 0xff000000;$srch=$src & 0x00ffffff;} if(!$id{$srcn,-1}) {$id{$srcn,-1} = ++$netcount;} if(!$id{$srcn,$srch}) {$id{$srcn,$srch} = ++$hstcount{$srcn};} $src=($id{$srcn,-1}<<16) + $id{$srcn,$srch}; vec($record,5,32)=$src; $dst=vec($record,6,32); $did=($dst>>28)&0xf; $dstn=$dst & 0xf0000000;$dsth=$dst & 0x0fffffff; if($did < 0xe) {$dstn=$dst & 0xffffff00;$dsth=$dst & 0x000000ff;} if($did < 0xc) {$dstn=$dst & 0xffff0000;$dsth=$dst & 0x0000ffff;} if($did < 0x8) {$dstn=$dst & 0xff000000;$dsth=$dst & 0x00ffffff;} if(!$id{$dstn,-1}) {$id{$dstn,-1} = ++$netcount;} if(!$id{$dstn,$dsth}) {$id{$dstn,$dsth} = ++$hstcount{$dstn};} $dst=($id{$dstn,-1}<<16) + $id{$dstn,$dsth}; vec($record,6,32)=$dst; $iprot=vec($record,17,8); if($iprot == 6){ syswrite(stdout,$record,44); }elsif($iprot == 17){ syswrite(stdout,$record,36); syswrite(stdout,$record,8); }else{ syswrite(stdout,$record,28); syswrite(stdout,$record,16); } }