From be527d670c50d6bbac90aec41cd87366e16515e4 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Wed, 01 Jun 2022 10:00:01 +0000
Subject: [PATCH] Added input argument for reliability testing

---
 test.c |   37 ++++++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/test.c b/test.c
index 2bef6e4..aae2c20 100644
--- a/test.c
+++ b/test.c
@@ -2,24 +2,31 @@
 #include <stdlib.h>
 #include "dns.h"
 #include <time.h>
+#include <netinet/ip.h>
 
 int main(void)
 {
-    char* hostname = "google.com";
-    char* IP = "127.0.0.1";
-    int type = T_A;
     unsigned char buf[65536];
-    struct timespec ret;
-    int r;
+    int error_count;
 
-    r = reachable(buf, IP);
-
-    /* ret = resolve(buf, hostname, IP, type); */
-
-    /* printf("%ld, %ld\n", ret.tv_sec, ret.tv_nsec); */
-
-    /* print_packet(buf); */
-    /* for (int i = 0; i < 98; i++) { */
-    /*     printf("%X", buf[i]); */
-    /* } */
+    error_count = 0;
+    for (int i = 0; i < 100; i++) {
+        error_count += (reachable(buf, "1.1.1.1") != 0);
+    }
+    printf("1.1.1.1: %d\n", error_count);
+    error_count = 0;
+    for (int i = 0; i < 100; i++) {
+        error_count += (reachable(buf, "192.168.0.101") != 0);
+    }
+    printf("192.168.0.101: %d\n", error_count);
+    error_count = 0;
+    for (int i = 0; i < 100; i++) {
+        error_count += (reachable(buf, "192.168.0.100") != 0);
+    }
+    printf("192.168.0.100: %d\n", error_count);
+    error_count = 0;
+    for (int i = 0; i < 100; i++) {
+        error_count += (reachable(buf, "129.146.153.226") != 0);
+    }
+    printf("129.146.153.226: %d\n", error_count);
 }

--
Gitblit v1.10.0