Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

is there a way for gephic to draw graphic for this

Once it's running

is there a way for gephic to draw graphic for this

Postby fedorafan » 17 Oct 2013 07:16

I have just started to use gephic and i am amazed by how cool this tool this, and here i have a simple question: is there a way for gephic to draw graphic where the input file has 4 columns.

for example, i have a network flow file, which looks like this

123.142.70.53 123 32.5.102.14 80
123.142.70.53 1234 47.124.137.45 80
123.142.70.53 1233 47.124.137.45 80
123.142.70.53 233 47.124.137.45 8080
123.142.70.27 1234 117.105.39.90 443
123.142.70.27 2234 51.88.64.126 8080
...
...
etc, etc

note the file has 4 columns, which represents src ip, src port, dst ip, dst port, and i want the tool to generate a diagram which can depit the connections (ips >ports>ports>ips ) shown in the file. I have the feeling that gephic is good at process data which has two columns so this probabaly is not possible, am i right? thanks
fedorafan
 
Posts: 4
Joined: 17 Oct 2013 07:01

Re: is there a way for gephic to draw graphic for this

Postby pegerp » 17 Oct 2013 09:16

Hi fedorafan

You should convert your data format from 4 column format to a 2 column format. Ie. your format should look like:
Code: Select all
srcIp dstPort
srcPort dstIp


You can use this sed script to convert from 4 column format to 2 column format:
Code: Select all
sed -r 's/([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/\1 \4/' 4col-data.csv > 2col-data.csv; # 1st and 4th columns
sed -r 's/([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/\2 \3/' 4col-data.csv >> 2col-data.txt; # 2nd and 3rd columns

Your question is more about converting data to a suitable format rather than capabilities of Gephi. Gephi can do what you require :) I also suggest that you take time to think what you want to accomplish / find out from such graph. Good luck!
pegerp
 
Posts: 101
Joined: 21 Dec 2011 18:10

Re: is there a way for gephic to draw graphic for this

Postby fedorafan » 17 Oct 2013 09:40

Hi pegerp,

Thank you for your reply, but i think converting the column from 4 to 2 will not do what i need here.

in my example above, i have more than 1 ip, so just breaking the columns to

srcip dstport
srcport dstip

will actually not show the matrix or relationships between the IPs and the ports. (some IPs have more then one srcport connecting to one dstport, while at the same time, these IPs also have connections to other dstips on different dstports.)


quote="pegerp"]Hi fedorafan

You should convert your data format from 4 column format to a 2 column format. Ie. your format should look like:
Code: Select all
srcIp dstPort
srcPort dstIp


You can use this sed script to convert from 4 column format to 2 column format:
Code: Select all
sed -r 's/([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/\1 \4/' 4col-data.csv > 2col-data.csv; # 1st and 4th columns
sed -r 's/([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/\2 \3/' 4col-data.csv >> 2col-data.txt; # 2nd and 3rd columns

Your question is more about converting data to a suitable format rather than capabilities of Gephi. Gephi can do what you require :) I also suggest that you take time to think what you want to accomplish / find out from such graph. Good luck![/quote]
fedorafan
 
Posts: 4
Joined: 17 Oct 2013 07:01

Re: is there a way for gephic to draw graphic for this

Postby fedorafan » 17 Oct 2013 15:14

basically what i want is something like this in the picture
Attachments
Untitled Note - Oct 17, 2013 9.06 PM - Page 3.png
fedorafan
 
Posts: 4
Joined: 17 Oct 2013 07:01

Re: is there a way for gephic to draw graphic for this

Postby pegerp » 17 Oct 2013 17:41

To encode the drawing with the duplicate "b" merged to a single node you'd do:
Code: Select all
srcIp srcPort
srcPort dstPort
dstPort dstIp

You can use the sed example to achieve this by adjusting the \1 \2 \3 and \4 parameters accordingly.

-- I wrote the below text first and I don't want to delete it now --

In your example graph you have two "b" nodes in the graph at the same time. This is possible to do in Gephi but you'd need to assign these nodes different IDs to separate them - eg. one "b" node that is a source and another "b" node that is the target. I still think the problem is more about what you want to accomplish and depending on that how you should pre-format your data.

For example prefix all IP addresses with "s" or "t" depending on whether they are a source or a target (you could add a 3rd column to be weight, A's weight to 80 would be 2).
Code: Select all
sA -> 80
sA -> 8080
456 -> tC
888 -> tC

Then if the C node were to connect to node A:80 you'd add an edge:
Code: Select all
sC -> 80
# and assuming C was using srcPort 555 to connect to A here would be an edge: 555 -> tA

This way you could inspect the graph so you can filter how much connections are made TO and FROM IPs and ports.

Another idea is that you combine the [IP:port] tuples to be single entities and keep the other tuple separated to IP and port:
Code: Select all
srcIp:srcPort --> dstIp
srcIp:srcPort --> dstPort
srcIp --> dstIp:dstPort
srcPort --> dstIp:dstPort

I recommend you take a look at GDF file format (https://gephi.org/users/supported-graph ... df-format/) to define the network. Regardless, it is more about pre-formatting the data than capabilities of Gephi.

---

To make this even longer this is probably how you are thinking your data - which is what Gephi currently cannot visualize since only 1 type of edge between two nodes is possible:
Code: Select all
A -[port=123,type=src]-> B
A -[port=80,type=dst]-> B

Something like that... that is not possible :P This is something that graph databases like Neo4j might be able to manage. However Neo4j is not going to visualize the graph (as well as Gephi) for you. Try to figure out what you want to accomplish and good luck with your project... I got myself confused as well ;) It really depends on what you want to find from the network.
pegerp
 
Posts: 101
Joined: 21 Dec 2011 18:10

Re: is there a way for gephic to draw graphic for this

Postby fedorafan » 18 Oct 2013 01:58

very much appreciated, i accidentally put duplicate B node in the drawing, which should have been one.

The solution you gave me is not exactly what i wanted but it did give me a workaround, :)

I will take a look at the gdf format, thanks again and have a great day!
fedorafan
 
Posts: 4
Joined: 17 Oct 2013 07:01


Return to How-To and Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

sports medicine portsmouth nh where to buy metronidazole