%description:
In this test the server shuts down immediately after (t = 0.0s) the starting and reboots
at t = 190s. Client acts according to its default behavior and starts sending DHCPDISCOVER
messages via UDP broadcasts.
As the client got no responses within its default timeout (60s) it periodically retransmits
the DHCPDISCOVER message.
In this scenario, server reboots at 190s so client has to retransmit DHCPDISCOVER four times
before its first success.

%inifile: omnetpp.ini
[General]
network = LifecycleTest
tkenv-plugin-path = ../../../etc/plugins
ned-path = .;../../../../src;../../lib
cmdenv-express-mode = false
sim-time-limit = 300s
record-eventlog = true

#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"

**.hasStatus = true
**.scenarioManager.script = xmldoc("scenario.xml")
**.numUdpApps = 1
**.client.udpApp[0].typename = "DHCPClient"
#**.client.udpApp[0].log-level = detail

**.server.udpApp[0].typename = "DHCPServer"
**.server.udpApp[0].numReservedAddresses = 100
**.server.udpApp[0].maxNumClients = 100
**.server.udpApp[0].dns = ""
**.server.udpApp[0].leaseTime = 150s

%file: test.ned

import inet.node.ethernet.Eth10M;
import inet.node.inet.StandardHost;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.common.lifecycle.LifecycleController;
import inet.common.scenario.ScenarioManager;

network LifecycleTest
{
    submodules:
        scenarioManager: ScenarioManager {
            @display("p=73,59");
        }
        lifecycleController: LifecycleController {
            @display("p=73,185");
        }
        configurator: IPv4NetworkConfigurator {
            parameters:
                config = xml("<config><interface hosts='server' address='192.168.1.1' netmask='255.255.255.0'/></config>");
                @display("p=73,116");
        }
        client: StandardHost {
            @display("p=205,124");
        }
        server: StandardHost {
            @display("p=553,124");
        }
    connections:
        client.ethg++ <--> Eth10M <--> server.ethg++;
}

%file: scenario.xml

<scenario>
    <at t="0.0">
        <tell module="lifecycleController" target="server" operation="NodeShutdownOperation"/>
    </at>
    <at t="190.0">
        <tell module="lifecycleController" target="server" operation="NodeStartOperation"/>
    </at>
</scenario>

%contains-regex: stdout
.*
LifecycleTest.server shut down
.*
Sending DHCPDISCOVER.
.*
(DETAIL: )?No DHCP offer received within timeout. Restarting.
.*
Sending DHCPDISCOVER.
.*
(DETAIL: )?No DHCP offer received within timeout. Restarting.
.*
Sending DHCPDISCOVER.
.*
(DETAIL: )?No DHCP offer received within timeout. Restarting.
.*
LifecycleTest.server started
.*
Sending DHCPDISCOVER.
.*
DHCPDISCOVER arrived. Handling it.
.*
The requested IP 192\.168\.1\.100/255\.255\.255\.0 is available. Assigning it to client.
.*
%#--------------------------------------------------------------------------------------------------------------
%not-contains: stdout
undisposed object:
%not-contains: stdout
-- check module destructor
%#--------------------------------------------------------------------------------------------------------------
