#!/usr/bin/perl

use strict;
use warnings;

my $sentfile = "senttime";
my $recvfile = "recvtime";
my $tempfile = "recvtime-temp";

`grep Sent output  |cut --delimiter=" "  -f3,6 >$sentfile`;
`grep received output | cut --delimiter=" " -f4,12 >$recvfile`;
`mv $recvfile $tempfile`;
`sort -n -u $tempfile >$recvfile`;

open(SENT, $sentfile) || die("Not able to open the file $sentfile\n");
open(RECV, $recvfile) || die("Not able to open the file $recvfile\n");

my @sentlist = <SENT>;
my @recvlist = <RECV>;

for (my $i = 0, my $j = 0; $i < $#sentlist; $i++)
{
	my @sentItems = split(" ", $sentlist[$i]);
	my @recvItems = split(" ", $recvlist[$j]);

	if ($sentItems[0] == $recvItems[0])
	{
#print "sentitem1 is $sentItems[1] \n";
#		print "recvitem1 is $recvItems[1] \n";
		my $kkk = $recvItems[1]-$sentItems[1];
        print "$sentItems[0] $kkk \n";
		$j++;
	}
	else
	{
		print "$sentItems[0] 100\n";
	}
}

