Changeset 7395b09
 Timestamp:
 11/20/18 14:27:21 (2 years ago)
 Branches:
 develop
 Children:
 a7132cf
 Parents:
 d5eb96d
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

examples/stats/ipdistgenplot.py
rd5eb96d r7395b09 187 187 plot.communicate() 188 188 189 # cleanup the temp file190 os.remove(dir + "/ipdist" + tick + ".tmp")191 192 189 # Generate plots for the timeseries data captured over the entire trace 193 190 for i in range(4): 194 for x in range(2): 195 plot = subprocess.Popen(['gnuplot persistent','p'], 196 shell=True, 197 stdin=subprocess.PIPE,) 198 plot.stdin.write("set term pngcairo size 1280,960\n") 191 plot = subprocess.Popen(['gnuplot persistent','p'], 192 shell=True, 193 stdin=subprocess.PIPE,) 194 plot.stdin.write("set term pngcairo size 1280,960\n") 195 plot.stdin.write("set output '" + dir + "/ipdistoctet" + str(i+1) + ".png'\n") 196 plot.stdin.write("set multiplot layout 3,1\n") 197 198 plot.stdin.write("set title 'CDF source octet " + str(i+1) + "'\n") 199 plot.stdin.write("set xlabel 'Prefix'\n") 200 plot.stdin.write("set ylabel 'Cumulative %'\n") 201 plot.stdin.write("set xrange[0:255]\n") 202 plot.stdin.write("set key off\n") 203 for x in range(len(dataFiles)): 204 dataFile = dataFiles[x] 205 filename,extension = dataFiles[x].split(".") 206 tick = filename.split("") 207 tick = tick[1] 208 199 209 if x == 0: 200 plot.stdin.write("set output '" + dir + "/ipdisttimeseriessrcoctet" + str(i+1) + ".png'\n") 201 plot.stdin.write("set title 'Timeseries src octet " + str(i+1) + "'\n") 210 plot.stdin.write("plot '" + dir + "/ipdist" + tick + ".tmp' using 2:1 index " + str(i) + " title '" + tick + "' with lines,") 202 211 else: 203 plot.stdin.write("set output '" + dir + "/ipdisttimeseriesdstoctet" + str(i+1) + ".png'\n") 204 plot.stdin.write("set title 'Timeseries dst octet " + str(i+1) + "'\n") 205 plot.stdin.write("set multiplot layout 2,1\n") 206 plot.stdin.write("set xtics rotate\n") 207 plot.stdin.write("set ytics\n") 208 plot.stdin.write("set xlabel 'Timestamp'\n") 209 plot.stdin.write("set key off\n") 210 plot.stdin.write("set autoscale xy\n") 212 plot.stdin.write(" '" + dir + "/ipdist" + tick + ".tmp' using 2:1 index " + str(i) + " title '" + tick + "' with lines,") 213 plot.stdin.write("\n") 214 215 plot.stdin.write("set title 'CDF destination octet " + str(i+1) + "'\n") 216 plot.stdin.write("set xlabel 'Prefix'\n") 217 plot.stdin.write("set ylabel 'Cumulative %'\n") 218 plot.stdin.write("set xrange[0:255]\n") 219 plot.stdin.write("set key off\n") 220 for x in range(len(dataFiles)): 221 dataFile = dataFiles[x] 222 filename,extension = dataFiles[x].split(".") 223 tick = filename.split("") 224 tick = tick[1] 225 211 226 if x == 0: 212 plot.stdin.write("plot '" + dir + "/ipdist srcoctet" + str(i+1) + ".timeseries' using 2:xtic(1) with lines title columnheader(2) at end smooth cumulative, for[i=3:257] '' using i with lines title columnheader(i) at end smooth cumulative\n")227 plot.stdin.write("plot '" + dir + "/ipdist" + tick + ".tmp' using 4:3 index " + str(i) + " title '" + tick + "' with lines,") 213 228 else: 214 plot.stdin.write("plot '" + dir + "/ipdistdstoctet" + str(i+1) + ".timeseries' using 2:xtic(1) with lines title columnheader(2) at end smooth cumulative, for[i=3:257] '' using i with lines title columnheader(i) at end smooth cumulative\n") 215 plot.stdin.write("set title 'Timeseries mean skewness'\n") 216 plot.stdin.write("set yrange[1:1]\n") 217 plot.stdin.write("set xlabel 'Timestamp'\n") 218 plot.stdin.write("set ylabel 'Skewness'\n") 219 plot.stdin.write("plot '" + dir + "/ipdisttimeseriesskewness.stats' using " + str((i*2)+2+x) + ":xtic(1) with lines\n") 220 plot.stdin.write("unset multiplot\n") 221 plot.stdin.flush() 222 plot.communicate() 229 plot.stdin.write(" '" + dir + "/ipdist" + tick + ".tmp' using 4:3 index " + str(i) + " title '" + tick + "' with lines,") 230 plot.stdin.write("\n") 231 232 plot.stdin.write("set title 'Timeseries mean skewness'\n") 233 plot.stdin.write("set yrange[1:1]\n") 234 plot.stdin.write("set xlabel 'Timestamp'\n") 235 plot.stdin.write("set ylabel 'Skewness'\n") 236 plot.stdin.write("set autoscale x\n") 237 plot.stdin.write("set key top right\n") 238 plot.stdin.write("unset xtics\n") 239 plot.stdin.write("plot '" + dir + "/ipdisttimeseriesskewness.stats' using " + str((i*2)+2) + ":xtic(1) title 'Source' with lines,") 240 plot.stdin.write("'' using " + str((i*2)+3) + ":xtic(1) title 'Destination' with lines\n") 241 plot.stdin.write("unset multiplot\n") 242 plot.stdin.flush() 243 plot.communicate() 244 245 246 # cleanup all tmp files 247 # tmp files created for CDF plots 248 for x in range(len(dataFiles)): 249 dataFile = dataFiles[x] 250 filename,extension = dataFiles[x].split(".") 251 tick = filename.split("") 252 tick = tick[1] 253 254 os.remove(dir + "/ipdist" + tick + ".tmp") 255 # skew file 256 os.remove(dir + "/ipdisttimeseriesskewness.stats") 257 # timeseries files 258 for x in range(4): 259 os.remove(dir + "/ipdistdstoctet" + str(x+1) + ".timeseries") 260 os.remove(dir + "/ipdistsrcoctet" + str(x+1) + ".timeseries")
Note: See TracChangeset
for help on using the changeset viewer.