Created
September 23, 2012 21:48
-
-
Save jjulian/3773152 to your computer and use it in GitHub Desktop.
Transform wireshark csv packet data into a Rickshaw graph of the most chatty ip addresses. Betascape 2012 example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No.,"Time","Source","Destination","Protocol","Length","Info" | |
---|---|
1,"0.000000000","10.10.83.34","255.255.255.255","UDP","82","Source | |
2,"0.414041000","10.10.83.236","10.10.83.255","NBNS","92","Name | |
3,"1.102041000","10.10.82.121","255.255.255.255","UDP","82","Source | |
4,"1.165016000","10.10.83.236","10.10.83.255","NBNS","92","Name | |
5,"1.860212000","10.10.81.190","255.255.255.255","DB-LSP-DISC","163","Dropbox | |
6,"1.862162000","10.10.81.190","10.10.83.255","DB-LSP-DISC","163","Dropbox | |
7,"1.914055000","10.10.83.236","10.10.83.255","NBNS","92","Name | |
8,"2.727106000","Cisco_44:41:c8","Broadcast","ARP","60","Who | |
9,"3.494374000","10.10.80.109","255.255.255.255","DB-LSP-DISC","313","Dropbox | |
10,"3.497962000","10.10.83.187","255.255.255.255","UDP","82","Source | |
11,"3.605393000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
12,"3.606050000","10.10.82.123","10.10.83.255","NBNS","92","Name | |
13,"3.606522000","10.10.82.123","10.10.83.255","NBNS","92","Name | |
14,"3.606991000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
15,"3.608032000","10.10.82.123","10.10.83.255","NBNS","92","Name | |
16,"3.608492000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
17,"3.609062000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
18,"4.777433000","10.10.80.223","10.10.81.255","BROWSER","253","Host | |
19,"4.824380000","10.10.82.123","10.10.83.255","NBNS","92","Name | |
20,"4.824801000","10.10.82.123","10.10.83.255","NBNS","92","Name | |
21,"4.825429000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
22,"4.825907000","10.10.82.123","10.10.83.255","BROWSER","216","Get | |
23,"4.958969000","Dell_f1:9a:63","Broadcast","ARP","60","Who | |
24,"5.600179000","10.10.82.149","255.255.255.255","UDP","82","Source | |
25,"5.836332000","10.10.82.224","255.255.255.255","UDP","82","Source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="rickshaw.min.css"> | |
</head> | |
<body> | |
<div id="chart"></div> | |
<script src="d3.min.js"></script> | |
<script src="d3.layout.min.js"></script> | |
<script src="rickshaw.min.js"></script> | |
<script> | |
var data = <%= JSON.generate(data_array) %>; | |
var graph = new Rickshaw.Graph( { | |
element: document.querySelector("#chart"), | |
renderer: 'bar', | |
width: 800, | |
height: 200, | |
series: [ { | |
color: 'steelblue', | |
data: data | |
} ] | |
} ); | |
graph.render(); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Transform wireshark csv packet data into a Rickshaw graph. | |
require 'json' | |
require 'erb' | |
traffic = File.open('betascape3.sample.csv').reduce({}) do |memo,line| | |
data = line.split(',').map { |d| d.gsub(/"/,'') } | |
# { source: data[2], dest: data[3], length: data[5].to_i } | |
memo[data[2]] ||= 0; | |
memo[data[2]] += 1; | |
memo | |
end | |
data_array = traffic.sort_by { |k,v| -v }.each_with_index.map { |row,i| {x: i, y: row.last} } | |
# puts JSON.generate(data_array) | |
puts ERB.new(File.read('graph.html.erb')).result(binding) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment