4 #include <sys/socket.h>
5 #include <netinet/in.h>
16 //-----------------------------------------------------------------------------
17 void AddRemoveTest(STG_PINGER & pinger)
19 addr = inet_addr("192.168.1.2");
20 pinger.AddIP(*(uint32_t*)&addr);
22 addr = inet_addr("192.168.1.2");
23 pinger.AddIP(*(uint32_t*)&addr);
27 printf("tree size=%d\n", pinger.GetPingIPNum());
31 addr = inet_addr("192.168.1.2");
32 pinger.DelIP(*(uint32_t*)&addr);
35 //pinger.PrintAllIP();
36 printf("tree size=%d\n", pinger.GetPingIPNum());
39 printf("tree size=%d\n", pinger.GetPingIPNum());
40 /*addr = inet_addr("192.168.1.2");
41 pinger.DelIP(*(uint32_t*)&addr);
43 addr = inet_addr("192.168.1.1");
44 pinger.DelIP(*(uint32_t*)&addr);
50 printf("tree size=%d\n", pinger.GetPingIPNum());
53 addr = inet_addr("192.168.1.4");
55 if (pinger.GetIPTime(*(uint32_t*)&addr, &t) == 0)
57 printf("192.168.1.4 t=%lu\n", t);
61 printf("192.168.1.4 not found\n");
65 addr = inet_addr("192.168.1.5");
66 if (pinger.GetIPTime(*(uint32_t*)&addr, &t) == 0)
68 printf("192.168.1.5 t=%lu\n", t);
72 printf("192.168.1.5 not found\n");
77 addr = inet_addr("192.168.1.3");
78 if (pinger.GetIPTime(*(uint32_t*)&addr, &t))
80 printf("IP not present\n");
84 printf("Ping time:\n");
88 //-----------------------------------------------------------------------------
89 void StressTest(STG_PINGER & pinger)
92 for (int i = 1; i <= 200; i++)
95 sprintf(s, "192.168.1.%d", i);
97 pinger.AddIP(*(uint32_t*)&addr);
102 printf("tree size=%d\n", pinger.GetPingIPNum());
104 for (int i = 1; i <= 200; i++)
107 sprintf(s, "192.168.1.%d", i);
109 pinger.DelIP(*(uint32_t*)&addr);
112 /*addr = inet_addr("192.168.1.2");
113 pinger.AddIP(*(uint32_t*)&addr);
115 addr = inet_addr("192.168.1.3");
116 pinger.AddIP(*(uint32_t*)&addr);*/
120 printf("tree size=%d\n", pinger.GetPingIPNum());
123 //-----------------------------------------------------------------------------
126 vector<PING_IP_TIME> pingIP;
128 STG_PINGER pinger(2);
132 printf("%s\n", pinger.GetStrError().c_str());
136 //AddRemoveTest(pinger);
143 //-----------------------------------------------------------------------------