Table Of Contents
Table Of Contents

Renaming a Module Parameter

The renaming of NED parameters can also cause regression; the parameter might be used by derived modules; a parameter setting in a derived module might not have the effect it had before; forgetting to update ini keys can also cause problems.

The following is a simplistic example for module parameter renaming causing a regression. The Router module sets the forwarding parameter to true which it inherits from NetworkLayerNodeBase. The latter uses the parameter to enable forwarding in its various submodules, such as Ipv4 and Ipv6:

module Router extends ApplicationLayerNodeBase
{
 parameters:
     forwarding = true;
module NetworkLayerNodeBase extends LinkLayerNodeBase
{
 parameters:
     bool forwarding = default(false);
     bool multicastForwarding = default(false);
     *.forwarding = forwarding;
     *.multicastForwarding = multicastForwarding;

In Ipv4NetworkLayer, we rename the forwarding parameter to unicastForwarding to make it similar to multicastForwading:

--- /docs/doc/src/tutorials/fingerprint/sources/Ipv4NetworkLayer.ned.orig
+++ /docs/doc/src/tutorials/fingerprint/sources/Ipv4NetworkLayer.ned.forwarding.modified
@@ -19,11 +19,11 @@
 module Ipv4NetworkLayer like INetworkLayer
 {
     parameters:
-        bool forwarding = default(false);
+        bool unicastForwarding = default(false);
         bool multicastForwarding = default(false);
         string interfaceTableModule;
         string displayStringTextFormat = default("%i");
-        *.forwarding = forwarding;
+        *.forwarding = unicastForwarding;
         *.multicastForwarding = multicastForwarding;
         *.interfaceTableModule = default(absPath(interfaceTableModule));
         *.routingTableModule = default(absPath(".routingTable"));

The Ipv4NetworkLayer module sets the forwarding parameters in its Ipv4 submodule to the value of unicastForwarding. Now, the forwarding = true key in Router doesn’t take effect in the router’s submodules, and the router doesn’t forward packets. This change causes the fingerprint tests/tplx fingerprint tests to fail:

$ inet_fingerprinttest -m RenamingParameter
. -f omnetpp.ini -c Ethernet -r 0  ... : FAILED

To correct the model, the renaming needs to be followed everywhere. When we change the deep parameter assignment of the forwarding parameter in NetworkLayerNodeBase to unicastForwarding, the fingerprint tests pass:

--- /docs/doc/src/tutorials/fingerprint/sources/NetworkLayerNodeBase.ned.orig
+++ /docs/doc/src/tutorials/fingerprint/sources/NetworkLayerNodeBase.ned.forwarding
@@ -17,7 +17,7 @@
         bool hasGn = default(false); 
         bool forwarding = default(false);
         bool multicastForwarding = default(false);
-        *.forwarding = forwarding;
+        *.unicastForwarding = forwarding;
         *.multicastForwarding = multicastForwarding;
         @figure[networkLayer](type=rectangle; pos=250,306; size=1000,130; fillColor=#00ff00; lineColor=#808080; cornerRadius=5; fillOpacity=0.1);
         @figure[networkLayer.title](type=text; pos=1245,311; anchor=ne; text="network layer");
$ inet_fingerprinttest -m RenamingParameter
. -f omnetpp.ini -c Ethernet -r 0  ... : PASS

This time we don’t have to accept the fingerprint changes, because they didn’t change.

Note

Before trying the following example, reset the model changes of the previous example.

Renaming module parameters can also lead to ERROR in the fingerprint tests. For example, we rename the queue submodule to txQueue in EtherMacFullDuplex.ned:

--- /docs/doc/src/tutorials/fingerprint/sources/EtherMacFullDuplex.ned.orig
+++ /docs/doc/src/tutorials/fingerprint/sources/EtherMacFullDuplex.ned.mod
@@ -149,7 +149,7 @@
         output upperLayerOut @labels(EtherFrame);  // to ~EtherEncap or ~IMacRelayUnit
         inout phys @labels(EtherFrame);            // to physical layer or the network
     submodules:
-        queue: <default("EtherQueue")> like IPacketQueue {
+        txQueue: <default("EtherQueue")> like IPacketQueue {
             parameters:
                 packetCapacity = default(1000);
                 @display("p=100,100");

When run the tplx fingerprint tests, they result in ERROR:

$ inet_fingerprinttest -m RenamingParameter
. -f omnetpp.ini -c Ethernet -r 0  ... : ERROR

This error message was omitted from the above output for simplicity:

Error: check_and_cast(): Cannot cast nullptr to type 'inet::queueing::IPacketQueue *'
-- in module (inet::EtherMacFullDuplex) RegressionTestingTutorialWired.router1.eth[0].mac (id=58),
during network initialization