Last active
August 29, 2015 14:11
-
-
Save cohalz/b7b732dc7ba3fe72f16d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
val seqr = """.*:(.*\..*)\sIP.*seq\s[0-9]+?:(.+?),""".r | |
val ackr = """.*:(.*\..*)\sIP.*?Flags\s\[\.\],\sack\s(.+?),\swin.*""".r | |
if(args.length > 0) { | |
val lines = Source.fromFile(args(0)).getLines().toList | |
val seqs = for { | |
line <- lines | |
seq <- seqr.findFirstMatchIn(line) | |
} yield List(seq.group(1),seq.group(2)) | |
val tmps = for { | |
line <- lines | |
ack <- ackr.findFirstMatchIn(line) | |
} yield List(ack.group(1),ack.group(2)) | |
val acks = for { | |
i <- 0 until tmps.length -1 | |
if tmps(i)(1) != tmps(i+1)(1) | |
} yield List(tmps(i)(0),tmps(i)(1)) | |
val time = for { | |
seq <- seqs | |
ack <- acks | |
if seq(1) == ack(1) | |
} yield ack(0).toDouble - seq(0).toDouble | |
println("average = " + time.sum/time.length) | |
} | |
else Console.err.println("Please enter inputfile") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment