%description:
Testing OSPF routing
    Backbone and 3 areas, Area1 connected to Backbone through Area3 used a VirtualLink
    UDP communications through entire network
%#--------------------------------------------------------------------------------------------------------------
%file: test.ned

import inet.linklayer.ethernet.EtherHub;
import inet.networklayer.autorouting.ipv4.IPv4NetworkConfigurator;
import inet.nodes.inet.StandardHost;
import inet.nodes.ospfv2.OSPFRouter;
import inet.util.ThruputMeteringChannel;


network Test1
{
    parameters:
        int numIRouters = default(0);
        @display("p=10,10;b=712,152");
    types:
        channel C extends ThruputMeteringChannel
        {
            delay = 0.1us;
            datarate = 100Mbps;
            thruputDisplayFormat = "#N";
        }
    submodules:
        H1: StandardHost {
            parameters:
                @display("p=56,92;i=device/laptop");
            gates:
                ethg[1];
        }
        N1: EtherHub {
            parameters:
                @display("p=184,182");
            gates:
                ethg[2];
        }
        RA1: OSPFRouter {
            gates:
                ethg[2];
        }
        RA1I[numIRouters]: OSPFRouter {
            gates:
                ethg[2];
        }
        R1: OSPFRouter {
            parameters:
                @display("p=296,92");
            gates:
                ethg[2];
        }
        RA3I[numIRouters]: OSPFRouter {
            gates:
                ethg[2];
        }
        R3: OSPFRouter {
            parameters:
                @display("p=296,92");
            gates:
                ethg[2];
        }
        RI[numIRouters]: OSPFRouter {
            gates:
                ethg[2];
        }
        R2: OSPFRouter {
            parameters:
                @display("p=416,92");
            gates:
                ethg[2];
        }
        RA2I[numIRouters]: OSPFRouter {
            gates:
                ethg[2];
        }
        RA2: OSPFRouter {
            gates:
                ethg[2];
        }
        N2: EtherHub {
            parameters:
                @display("p=532,182");
            gates:
                ethg[2];
        }
        H2: StandardHost {
            parameters:
                @display("p=660,92;i=device/laptop");
            gates:
                ethg[1];
        }
        configurator: IPv4NetworkConfigurator {
            parameters:
                config = xml("<config>"+
                            "<interface among='H1 RA1 RA1I[*] R1' address='192.168.1.x' netmask='255.255.255.x' />"+
                            "<interface among='R1 RA3I[*] R3' address='192.168.3.x' netmask='255.255.255.x' />"+
                            "<interface among='R3 RI[*] R2' address='192.168.60.x' netmask='255.255.255.x' />"+
                            "<interface among='H2 RA2 RA2I[*] R2' address='192.168.2.x' netmask='255.255.255.x' />"+
                            "<route hosts='H1 H2' destination='*' netmask='0.0.0.0' interface='eth0' />"+
                            "</config>");
                addStaticRoutes = false;
                addDefaultRoutes = false;
                @display("p=75,43");
        }
    connections:
        H1.ethg[0] <--> C <--> N1.ethg[0];
        N1.ethg[1] <--> C <--> RA1.ethg[0];
        RA1.ethg[1] <--> C <--> R1.ethg[0] if numIRouters == 0;
        RA1.ethg[1] <--> C <--> RA1I[0].ethg[0] if numIRouters > 0;
        for i = 1..numIRouters-1 {
            RA1I[i-1].ethg[1] <--> C <--> RA1I[i].ethg[0];
        }
        RA1I[numIRouters-1].ethg[1] <--> C <--> R1.ethg[0] if numIRouters > 0;


        R1.ethg[1] <--> C <--> R3.ethg[0] if numIRouters == 0;
        R1.ethg[1] <--> C <--> RA3I[0].ethg[0] if numIRouters > 0;
        for i = 1..numIRouters-1 {
            RA3I[i-1].ethg[1] <--> C <--> RA3I[i].ethg[0];
        }
        RA3I[numIRouters-1].ethg[1] <--> C <--> R3.ethg[0] if numIRouters > 0;



        R3.ethg[1] <--> C <--> R2.ethg[0] if numIRouters == 0;
        R3.ethg[1] <--> C <--> RI[0].ethg[0] if numIRouters > 0;
        for i = 1..numIRouters-1 {
            RI[i-1].ethg[1] <--> C <--> RI[i].ethg[0];
        }
        RI[numIRouters-1].ethg[1] <--> C <--> R2.ethg[0] if numIRouters > 0;

        R2.ethg[1] <--> C <--> RA2.ethg[0] if numIRouters == 0;
        R2.ethg[1] <--> C <--> RA2I[0].ethg[0] if numIRouters > 0;
        for i = 1..numIRouters-1 {
            RA2I[i-1].ethg[1] <--> C <--> RA2I[i].ethg[0];
        }
        RA2I[numIRouters-1].ethg[1] <--> C <--> RA2.ethg[0] if numIRouters > 0;

        RA2.ethg[1] <--> C <--> N2.ethg[0];
        N2.ethg[1] <--> C <--> H2.ethg[0];
}


%#--------------------------------------------------------------------------------------------------------------
%inifile: omnetpp.ini

[General]
description = "Simple test"
network = Test1
ned-path = .;../../../../src;../../lib
tkenv-plugin-path = ../../../etc/plugins
sim-time-limit = 200s

#omnetpp 5.0 - 5.1 compatibility:
eventlog-file = "${resultdir}/${configname}-${runnumber}.elog"
output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"
output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
snapshot-file = "${resultdir}/${configname}-${runnumber}.sna"

**.ospf.ospfConfig = xmldoc("ASConfig.xml")

**.numUdpApps = 2
**.udpApp[0].typename = "UDPBasicApp"
**.udpApp[0].destPort = 1234
**.udpApp[0].messageLength = 32 bytes
**.udpApp[0].sendInterval = 1s
**.udpApp[0].startTime = 59s
**.udpApp[0].stopTime = this.startTime + 100s
**.H2.udpApp[0].destAddresses = "H1"
**.H1.udpApp[0].destAddresses = "H2"
**.udpApp[1].typename = "UDPEchoApp"
**.udpApp[1].localPort = 1234

**.arp.cacheTimeout = 1s

**.numIRouters = ${0,1,2,3,4,5,6}

%#--------------------------------------------------------------------------------------------------------------
%file: ASConfig.xml
<?xml version="1.0"?>
<OSPFASConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="OSPF.xsd">

  <!-- Areas -->
  <Area id="0.0.0.0">
    <AddressRange address="192.168.60.0" mask="255.255.255.0" status="Advertise" />
  </Area>

  <Area id="0.0.0.1">
    <AddressRange address="192.168.1.0" mask="255.255.255.0" status="Advertise" />
  </Area>

  <Area id="0.0.0.2">
    <AddressRange address="192.168.2.0" mask="255.255.255.0" status="Advertise" />
  </Area>

  <Area id="0.0.0.3">
    <AddressRange address="192.168.3.0" mask="255.255.255.0" status="Advertise" />
  </Area>

  <!-- Routers -->
  <Router name="RA1" RFC1583Compatible="true">
    <HostInterface ifName="eth0" areaID="0.0.0.1" attachedHost="H1" linkCost="10" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" interfaceOutputCost="2" />
  </Router>

  <Router name="RA1I[*]" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.1" interfaceOutputCost="2" />
  </Router>

  <Router name="R1" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.1" interfaceOutputCost="1" routerPriority="1" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.3" interfaceOutputCost="2" />
    <VirtualLink endPointRouterID="R3%routerId" transitAreaID="0.0.0.3" />
  </Router>

  <Router name="RI[*]" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="2" />
  </Router>

  <Router name="R2" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.0" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.2" interfaceOutputCost="1" routerPriority="2" />
  </Router>

  <Router name="RA2I[*]" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.2" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.2" interfaceOutputCost="2" />
  </Router>

  <Router name="RA2" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.2" interfaceOutputCost="2" />
    <HostInterface ifName="eth1" areaID="0.0.0.2" attachedHost="H1" linkCost="10" />
  </Router>

  <Router name="R3" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.3" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.0" interfaceOutputCost="1" routerPriority="2" />
    <VirtualLink endPointRouterID="R1%routerId" transitAreaID="0.0.0.3" />
  </Router>

  <Router name="RA3I[*]" RFC1583Compatible="true">
    <BroadcastInterface ifName="eth0" areaID="0.0.0.3" interfaceOutputCost="2" />
    <BroadcastInterface ifName="eth1" areaID="0.0.0.3" interfaceOutputCost="2" />
  </Router>

</OSPFASConfig>

%#--------------------------------------------------------------------------------------------------------------
%contains: results/General-0.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-0.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-0.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-0.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-0.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-0.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-1.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-1.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-1.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-1.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-1.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-1.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-2.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-2.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-2.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-2.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-2.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-2.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-3.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-3.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-3.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-3.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-3.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-3.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-4.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-4.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-4.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-4.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-4.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-4.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-5.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-5.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-5.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-5.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-5.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-5.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%contains: results/General-6.sca
scalar Test1.H1.udpApp[0] 	sentPk:count 	100
%contains: results/General-6.sca
scalar Test1.H1.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-6.sca
scalar Test1.H1.udpApp[1] 	echoedPk:count 	100
%contains: results/General-6.sca
scalar Test1.H2.udpApp[0] 	sentPk:count 	100
%contains: results/General-6.sca
scalar Test1.H2.udpApp[0] 	rcvdPk:count 	100
%contains: results/General-6.sca
scalar Test1.H2.udpApp[1] 	echoedPk:count 	100
%#--------------------------------------------------------------------------------------------------------------
%not-contains: stdout
undisposed object:
%not-contains: stdout
-- check module destructor
%#--------------------------------------------------------------------------------------------------------------
