public void TestFieldExtraction() { ScamperTraceroute currentTraceroute = null; foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"App_Data\ScamperSample1.txt")) { currentTraceroute = traceroute; } Assert.AreEqual(IPAddress.Parse("129.186.1.240"), currentTraceroute.Source); Assert.AreEqual(IPAddress.Parse("2.50.184.243"), currentTraceroute.Destination); Assert.AreEqual(7, currentTraceroute.ListId); Assert.AreEqual(5520, currentTraceroute.CycleId); Assert.AreEqual(1489105699, currentTraceroute.Timestamp); Assert.AreEqual(new DateTime(2017, 3, 10, 0, 28, 19), currentTraceroute.TraceStartDateTime); Assert.AreEqual(DestReplied.NotReplied, currentTraceroute.DestinationReplied); Assert.AreEqual(0, currentTraceroute.DestinationRTT); Assert.AreEqual(0, currentTraceroute.RequestTTL); Assert.AreEqual(0, currentTraceroute.ReplyTTL); Assert.AreEqual(HaltReason.GapDetected, currentTraceroute.HaltReason); Assert.AreEqual("0", currentTraceroute.HaltReasonData); Assert.AreEqual(PathComplete.Incomplete, currentTraceroute.PathComplete); Assert.AreEqual(14, currentTraceroute.Hops.Count); var lastHop = currentTraceroute.Hops[13]; Assert.AreEqual(2, lastHop.IPs.Count); var lastIPInfoInHop = lastHop.IPs[1]; Assert.AreEqual(IPAddress.Parse("10.246.250.98"), lastIPInfoInHop.IP); Assert.AreEqual(246.193m, lastIPInfoInHop.RTT); Assert.AreEqual(3, lastIPInfoInHop.Tries); }
static void Main(string[] args) { var counter = 0; ScamperTraceroute currentTraceroute = null; foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"D:\Downloads\daily.txt")) { ////Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} - {1} - {2}", traceroute.Source, traceroute.Destination, traceroute.Hops.Count)); counter++; currentTraceroute = traceroute; if (counter % 10000 == 0) { Console.WriteLine(counter); } } foreach (var neighborPair in currentTraceroute.FindLatencyNeighbors()) { Console.WriteLine(neighborPair); } Console.WriteLine("Done!"); Console.ReadKey(); }
public void TestNeighborsMaxHopDiff() { ScamperTraceroute currentTraceroute = null; foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"App_Data\ScamperSample1.txt")) { currentTraceroute = traceroute; } var neighborPairs = currentTraceroute.FindLatencyNeighbors(maxHopDifference: 2); Assert.AreEqual(9, neighborPairs.Count); }
public void TestNeighbors() { ScamperTraceroute currentTraceroute = null; foreach (var traceroute in TracerouteTextDumpParser.ParseFile(@"App_Data\ScamperSample1.txt")) { currentTraceroute = traceroute; } var neighborPairs = currentTraceroute.FindLatencyNeighbors(); Assert.AreEqual(10, neighborPairs.Count); var lastPair = neighborPairs[neighborPairs.Count - 1]; Assert.AreEqual(IPAddress.Parse("195.229.4.97"), lastPair.Neighbor1); Assert.AreEqual(IPAddress.Parse("10.246.250.98"), lastPair.Neighbor2); Assert.AreEqual(12, lastPair.Neighbor1HopIndex); Assert.AreEqual(13, lastPair.Neighbor2HopIndex); Assert.AreEqual(1, lastPair.DiffDistanceInHops); Assert.AreEqual((decimal)0.1, lastPair.LatencyDiff); }