head -25000000 /var/sipenv-91.121.75.124/log/sip.log.0 | perl -e ' $answ1="SIP/2.0 100 Your Re-INVITE is received"; $answ2="SIP/2.0 488 Your Re-INVITE is ignored"; $n=1; while(<>) { #03 Feb 16:37:39.932/GLOBAL/ser[76763]: SENDING message to 83.77.6.211:5060: #03 Feb 16:37:40.035/GLOBAL/ser[76765]: RECEIVED message from 84.73.184.232:64309: if(/^\d\d ... ..:..:..\.\d\d\d.*: (SENDING message to|RECEIVED message from) .*:[\r\n]*$/) { $h1=$_; $nh1=$n; } #See http://www.ietf.org/rfc/rfc3261.txt [Page 253] if(/^(SIP\/2.0|INVITE|ACK|BYE|CANCEL|REGISTER|OPTIONS|INFO|NOTIFY|SUBSCRIBE) /) { $h2=$_; $nh2=$n; } if(/^Call-ID: /) { $id=$_; $nid=$n; if($h2=~/^(BYE|SIP\/2.0 \d\d\d Your Re-INVITE is) /) { if($nid-$nh1<=25 && $nid-$nh2<=25 && $nh2==$nh1+1) { $h2=~s/[\r\n]//g; $id=~s/[\r\n]//g; $id=~s/^Call-ID: //; # $h1=~/^(\d\d) (...) (..):(..):(..)\.(\d\d\d).*: (SENDING|RECEIVED) message (to|from) (.*):[\r\n]*$/; $dd=$1; $mmm=$2; $hh=$3; $mm=$4; $ss=$5; $ms=$6; $dir=($8 eq "from")?"R":"T"; $comm=$9; $time=$hh*3600+$mm*60+$ss+$ms/1000; # if($h2 eq $answ1) { $call{$id}=$time; $nansw1++; } else { if(defined $call{$id}) { if($h2 ne $answ2) { printf "%s %s %s:%s:%s %9.4f %s\n",$mmm,$dd,$hh,$mm,$ss,$time-$call{$id},$h2; } delete $call{$id}; } } #printf "%s %02d %02d:%02d:%02d.%03d,%s,%s,%s,%s\n", # $mmm,$dd,$hh,$mm,$ss,$ms,$id,$dir,$comm,$h2; } else { #printf "\nERROR: headers of Call-ID are not found\n"; #exit; } } } $n++; } #foreach $id (keys %call) #{ # print $call{$id}." ".$id."\n"; #} '