// Use dokuwiki graphviz plugin to describe a network

Graphviz plugin allows embedding of .dot graphs into dokuwiki pages, put a graph description inside the tag <graphviz> is enough to accomplish this task, for more info about graphviz and the plugin installation see references below.


Use .dot file to describe graphically a not so unusual network scenario with InterNET, DMZ and LAN.


Hub-like object

To describe a lan where many machines are connected dot provides a primitive type named record.

Each cell of a record is identified by the id surrounded by angle brackets.

To address a cell you must use the syntax “<record id>:<cell id>”.

    INET [shape=record,width=.1, height=.1, label="<0>InterNET        |<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];

Use ranking to pretty place machines

To allow a good placement of machines items we can use the rank = same attribute to align group of items to invisible rank generator objects.

And then:

     { rank = same; inv1; Alpha; Gamma; }

Graphical vs. logical edges placement

When an arrow has an opposite direction then the diagram (rankdir attribute) I strongly recommend to follow the diagram direction and set the dir attribute with the value back.

    INET:2 -> Alpha [dir=back];


A node port is a point where edges can attach to a node. If you want to specify where an edge is connected to an object you can use headport and tailport attributes specifying the compass point that you prefer “n”, “ne”, … .

    INET:10 -> Gold [dir=back, headport=e, tailport=s];
    INET:11 -> Platinum [dir=back, headport=e, tailport=s];

The code

Here all the code required to compose the diagram.

digraph structs {
    size = "5,5";
    node [shape=box, width=.1, height=.1, layer=all];
    edge [layer=all];
    constraint = false;
    nodesep = .1;
    ranksep = .3;
        node [style=invis];
        inv1; inv2; inv3; inv4;

    INET [shape=record,width=.1, height=.1, label="<0>InterNET        |<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];
    DMZ [shape=record,width=.1, height=.1, label="<0>DMZ|<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];
    LAN [shape=record,width=.1, height=.1, label="<0>LAN|<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];

    INET:0 -> inv1 -> inv2 -> DMZ:0 -> inv3 -> inv4 -> LAN:0 [style=invis];

    { rank = same; inv1; Alpha; Gamma; }
    { rank = same; inv2; Beta; } 

    INET:2 -> Alpha [dir=back];
    INET:5 -> Beta [dir=back];
    INET:8 -> Gamma [dir=back];
    Alpha -> DMZ:2;
    Beta -> DMZ:5;
    Gamma -> DMZ:8;    

    { rank = same; inv3; Gold; }
    { rank = same; inv4; Silver; Platinum;} 

    DMZ:2 -> Silver [dir=back];
    DMZ:5 -> Gold [dir=back];
    DMZ:8 -> Platinum [dir=back];
    Silver -> LAN:2;
    Gold -> LAN:5;
    Platinum -> LAN:8;    

    INET:10 -> Gold [dir=back, headport=e, tailport=s];
    INET:11 -> Platinum [dir=back, headport=e, tailport=s];


Keeping in mind that digraph's diagrams are oriented and that exists some rules to change it's rendering behavior you can reach a great control on its output.


QR Code: URL of current page
QR Code: URL of current page start (generated for current page)
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported