diff options
| author | Kumar Damani <kumar.damani@mail.utoronto.ca> | 2018-11-21 23:27:49 +0000 |
|---|---|---|
| committer | Kumar Damani <kumar.damani@mail.utoronto.ca> | 2018-11-21 23:27:49 +0000 |
| commit | ff0e28fbdfe8fd9f8fbaa9559834fee8f4dbcecc (patch) | |
| tree | 740e1fee55a6629e65af4993d340df0aa8c513d6 /code/perpacket/packet_length_cdf.R | |
| parent | 09af1849763528d2d66f51025755d848ceb6b7e9 (diff) | |
all remaining files
Diffstat (limited to 'code/perpacket/packet_length_cdf.R')
| -rw-r--r-- | code/perpacket/packet_length_cdf.R | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/code/perpacket/packet_length_cdf.R b/code/perpacket/packet_length_cdf.R new file mode 100644 index 0000000..24bf486 --- /dev/null +++ b/code/perpacket/packet_length_cdf.R @@ -0,0 +1,31 @@ +data_all= read.csv(file="../../data/perpacket/packet_lengths_all.csv", header=TRUE, sep=",") +data_ip = read.csv(file="../../data/perpacket/packet_lengths_ip.csv", header=TRUE, sep=",") +data_tcp = read.csv(file="../../data/perpacket/packet_lengths_tcp.csv", header=TRUE, sep=",") +data_udp = read.csv(file="../../data/perpacket/packet_lengths_udp.csv", header=TRUE, sep=",") +data_nonip = read.csv(file="../../data/perpacket/packet_lengths_nonip.csv", header=TRUE, sep=",") + +all_counts = data_all$Count[-1] +ip_counts = data_ip$Count[-1] +tcp_counts = data_tcp$Count[-1] +udp_counts = data_udp$Count[-1] +nonip_counts = data_nonip$Count[-1] + +all_probs = cumsum(all_counts)/data_all$Count[1] +ip_probs = cumsum(ip_counts)/data_ip$Count[1] +tcp_probs = cumsum(tcp_counts)/data_tcp$Count[1] +udp_probs = cumsum(udp_counts)/data_udp$Count[1] +udp_probs = cumsum(udp_counts)/data_udp$Count[1] +nonip_probs = cumsum(nonip_counts)/data_nonip$Count[1] + +lengths = c(0,20,40,80,160,320,640,1280,2560,5120) +log_lengths = log(lengths,2) + +plot(log_lengths, all_probs, col="red", type="S", main="CDF of packet lengths of ALL, IP, TCP, UDP, and NON-IP packets", xlab="log_2 packet lengths", ylab="probability") +lines(log_lengths, ip_probs, col="blue", type="S") +lines(log_lengths, tcp_probs, col="green", type="S") +lines(log_lengths, udp_probs, col="cyan", type="S") +lines(log_lengths, nonip_probs, col="pink", type="S") +legend(10,0.2, legend=c("All","IP", "TCP", "UDP", "Non-IP"), col=c("red", "blue", "green", "cyan", "pink"), lty=1) +dev.print(png, '../../plots/perpacket/packetsize_all.png', width=500) + +quit() |
