X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=src%2Flibswift_udp%2Fmfold%2Flogparse;fp=src%2Flibswift_udp%2Fmfold%2Flogparse;h=03c4d863dfb1a014ca5514e28372263a0aba39e8;hb=46f3ca346fe499ba3e8f595fc5c2aa2b3e3c4d5f;hp=0000000000000000000000000000000000000000;hpb=d8da6fc1273a2acee935a15761b77a73424faef5;p=swifty.git diff --git a/src/libswift_udp/mfold/logparse b/src/libswift_udp/mfold/logparse new file mode 100755 index 0000000..03c4d86 --- /dev/null +++ b/src/libswift_udp/mfold/logparse @@ -0,0 +1,185 @@ +#!/usr/bin/perl -w + +$SERVER=shift; +%PORTS = (); +%HOSTS = (); +%CHANN = ( "#0" => "none" ); +%EVENTS = ( "#0" => {"+hs"=>0} ); +%SENT = (); +%RCVD = (); +%DSENT = (); +%DRCVD = (); +%CWNDLOG = (); +%RTTLOG = (); +%OWDLOG = (); +%TDATALOG = (); +%RDATALOG = (); +%INDATALOG = (); +$SENTB = 0; +$RCVDB = 0; + +open(SRVP,$ENV{"HOME"}."/swift/mfold/servers.txt") or die; +while () { + /(\S+):(\d+)/ or next; + $PORTS{$1} = $2; +} +close SRVP; + +open(SRV,$ENV{"HOME"}."/.ssh/config") or die; +while () { + if (/Host (\S+)/) { + $srvname=$1; + $port = $PORTS{$srvname}; + } + $HOSTS{$1}{$port}=$srvname if /HostName (\S+)/ && $port; +} +close SRV; + +while (<>) { + /(\d+_\d+_\d+_\d+_\d+) (#\d+) (\S+) (.*)/ or next; + my $time = $1; + my $channel = $2; + my $event = $3; + my $rest = $4; + my $host = $CHANN{"$channel"}; + $host = "unknown" if not $host; + $time =~ /^(\d+)_(\d+)_(\d+)_(\d+)/; + my $ms=$1*60; $ms=($ms+$2)*60; $ms=($ms+$3)*1000; $ms+=$4; + if ($event eq "sent") { + $rest =~ /(\d+)b ([\d\.]+):(\d+):/; + $ip = $2; + $port = $3; + $host = $HOSTS{$ip}{$port}; + #$SENT{$h} = 0 if not exists $SENT{$h}; + $SENT{$host} += $1; + $SENTB += $1; + $DSENT{$host}++; + $CHANN{"$channel"} = $host; + } elsif ($event eq "recvd") { + $rest =~ /(\d+)/; + #$RCVD{$h} = 0 if not exists $RCVD{$h}; + $DRCVD{$host}++; + $RCVD{$host} += $1; + $RCVDB += $1; + } elsif ($event eq "sendctrl") { + if ($rest =~ /cwnd (\d+\.\d+).*data_out (\d+)/) { + if (not exists $CWNDLOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-cwnd.log") or die; + $CWNDLOG{$host} = $handle; + } + print {$CWNDLOG{$host}} "$ms\t$1\t$2\n"; + } elsif ($rest =~ /ledbat (\-?\d+)\-(\-?\d+)/) { + if (not exists $OWDLOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-owd.log") or die; + $OWDLOG{$host} = $handle; + } + print {$OWDLOG{$host}} "$ms\t$1\t$2\n"; + } elsif ($rest =~ /rtt (\d+) dev (\d+)/) { + if (not exists $RTTLOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-rtt.log") or die; + $RTTLOG{$host} = $handle; + } + print {$RTTLOG{$host}} "$ms\t$1\t$2\n"; + } + } elsif ($event eq "Tdata") { + if (not exists $TDATALOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-tdata.log") or die; + $TDATALOG{$host} = $handle; + } + print {$TDATALOG{$host}} "$ms\n"; + } elsif ($event eq "Rdata") { + if (not exists $RDATALOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-rdata.log") or die; + $RDATALOG{$host} = $handle; + } + print {$RDATALOG{$host}} "$ms\n"; + } elsif ($event eq "-data" && $rest =~ /\(0,(\d+)\)/) { + my $bin = $1; + if (not exists $INDATALOG{$host}) { + open(my $handle, '>', "$SERVER-harvest/$SERVER-$host-indata.log") or die; + $INDATALOG{$host} = $handle; + } + print {$INDATALOG{$host}} "$bin\t$ms\n"; + } + $EVENTS{"$host"} = { "+hs"=>0 } if not exists $EVENTS{"$host"}; + + print "$time $SERVER $host$channel $event $rest\n"; + + # DO STATS + $EVENTS{"$host"}{"$event"} = 0 if not exists $EVENTS{"$host"}{"$event"}; + $EVENTS{"$host"}{"$event"}++; + +} + +for $host (keys %CWNDLOG) { + close($CWNDLOG{$host}); +} +for $host (keys %OWDLOG) { + close ($OWDLOG{$host}); +} +for $host (keys %RTTLOG) { + close ($RTTLOG{$host}); +} +for $host (keys %TDATALOG) { + close ($TDATALOG{$host}); +} +for $host (keys %RDATALOG) { + close ($RDATALOG{$host}); +} +for $host (keys %INDATALOG) { + close ($INDATALOG{$host}); +} + +open(LEGEND,"> $SERVER-harvest/$SERVER-legend.txt") or die; + +for $channel (keys %CHANN) { + my $host = $CHANN{"$channel"}; + print LEGEND "$channel\t$host\n"; + open(STATS,"> $SERVER-harvest/$SERVER-$host.stat") or die; + my %events = %{ $EVENTS{"$host"} }; + for $event ( keys %events ) { + print STATS "$event\t".($events{"$event"})."\n"; + } + close STATS; + open(HTML,"> $SERVER-harvest/$SERVER-$host.html") or die; + print HTML "\n"; + my $rcvd = $RCVD{$host}; + my $sent = $SENT{$host}; + $rcvd=0.001 if not $rcvd; + $sent=0.001 if not $sent; + printf HTML + "". + "\n", + $sent, $SENTB?$sent/$SENTB*100:0, $rcvd, $RCVDB?$rcvd/$RCVDB*100:0; + print HTML + "\n"; + printf HTML + "\n", + $events{"+data"}, ($events{"+data"}*1029)/$sent*100, + $events{"-data"}, ($events{"-data"}*1029)/$rcvd*100; + printf HTML + "\n", + $events{"+hash"}, ($events{"+hash"}*25)/$sent*100, + $events{"-hash"}, ($events{"-hash"}*25)/$rcvd*100; + printf HTML + "\n", + $events{"+ack"}, ($events{"+ack"}*5)/$sent*100, + $events{"-ack"}, ($events{"-ack"}*5)/$rcvd*100; + printf HTML + "\n", + $events{"+hint"}, ($events{"+hint"}*5)/$sent*100, + $events{"-hint"}, ($events{"-hint"}*5)/$rcvd*100; + printf HTML + "\n", + $events{"+hs"}, $events{"-hs"}; + my $losses = $events{"+data"}>0 ? + ($events{"Rdata"}+$events{"Tdata"})/$events{"+data"}*100 : 0; + printf HTML + "\n", + $events{"Rdata"}, $events{"Tdata"}, + $events{"Rdata"}+$events{"Tdata"}, $losses; + + print HTML "
sentrcvd
bytes%i/%.1f%%%i/%.1f%%
dgrams".$DSENT{$host}."".$DRCVD{$host}."
data%i/%.1f%%%i/%.1f%%
hash%i/%.1f%%%i/%.1f%%
ack%i/%.1f%%%i/%.1f%%
hint%i/%.1f%%%i/%.1f%%
hs%i%i
lossesR:%i+T:%i=%i/%.1f%%
\n"; + close HTML; +} +close LEGEND;