def testForSDN(testMethod, dstIP, count, interval):
global verbose
rtt = []
sentMS = 0
if(testMethod == "icmp"):
sdnpwn.message("Testing with ICMP", sdnpwn.NORMAL)
icmp = (IP(dst=dstIP)/ICMP())
for i in range(0,count):
sentMS = int(round(time.time() * 1000))
resp = sr1(icmp)
rtt.append((int(round(time.time() * 1000))) - sentMS)
time.sleep(interval)
elif(testMethod == "arp"):
sdnpwn.message("Testing with ARP", sdnpwn.NORMAL)
for i in range(0,count):
sentMS = int(round(time.time() * 1000))
resp = arping(dstIP)
rtt.append((int(round(time.time() * 1000))) - sentMS)
time.sleep(interval)
initValue = rtt[0]
rtt.pop(0)
#Perform T-Test to check if first latency value is significantly different from others in our sample
res = stats.ttest_1samp(rtt, initValue)
if(verbose == True):
sdnpwn.message("Initial RTT: " + str(initValue), sdnpwn.VERBOSE)
sdnpwn.message("RTTs for other traffic: " + str(rtt), sdnpwn.VERBOSE)
sdnpwn.message("Calculated p-value for inital RTT is " + str(res[1]), sdnpwn.VERBOSE)
if(res[1] < .05 and all(i < initValue for i in rtt)): #If the p-value is less that 5% we can say that initValue is significant
return True
else:
return False
评论列表
文章目录