To implement Network Namespaces in OMNeT++, we need to generate the individually isolated network part which indicates multiple namespaces. Every namespace can have its personal set of network nodes (hosts, routers etc.) and communication among the namespaces can be controlled or limited based on the design. Get best simulation guidance from omnet-manual.com.
This is how you can implement a basic network namespaces setup in OMNeT++ using the INET framework:
Step-by-Step Implementation:
Start by generating a network topology in which we set up a separate isolated network segments to indicate multiple namespaces. This segments can be linked via routers or gateways if inter-namespace communication is required.
Example NED File (NamespaceNetwork.ned):
package mynetwork;
import inet.node.inet.StandardHost;
import inet.node.inet.Router;
import inet.node.ethernet.EtherSwitch;
network NamespaceNetwork
{
submodules:
// Namespace 1
router1: Router {
@display(“p=100,200”);
}
hostA: StandardHost {
@display(“p=50,100”);
}
hostB: StandardHost {
@display(“p=150,100”);
}
switch1: EtherSwitch {
@display(“p=100,150”);
}
// Namespace 2
router2: Router {
@display(“p=300,200”);
}
hostC: StandardHost {
@display(“p=250,100”);
}
hostD: StandardHost {
@display(“p=350,100”);
}
switch2: EtherSwitch {
@display(“p=300,150”);
}
// Gateway for inter-namespace communication
gatewayRouter: Router {
@display(“p=200,300”);
}
connections allowunconnected:
// Connections for Namespace 1
hostA.ethg++ <–> ethernetLine <–> switch1.ethg++;
hostB.ethg++ <–> ethernetLine <–> switch1.ethg++;
switch1.ethg++ <–> ethernetLine <–> router1.ethg++;
// Connections for Namespace 2
hostC.ethg++ <–> ethernetLine <–> switch2.ethg++;
hostD.ethg++ <–> ethernetLine <–> switch2.ethg++;
switch2.ethg++ <–> ethernetLine <–> router2.ethg++;
// Optional inter-namespace connection through a gateway
router1.ethg++ <–> ethernetLine <–> gatewayRouter.ethg++;
router2.ethg++ <–> ethernetLine <–> gatewayRouter.ethg++;
}
Allocate IP addresses to the hosts and routers in each namespace. Make sure that the namespaces are isolated by using several IP address ranges. Set up routing to control communication amongst namespaces if required.
Example Configuration in omnetpp.ini:
network = NamespaceNetwork
# Namespace 1 Configuration
**.hostA.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.hostA.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
**.hostB.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.hostB.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
**.router1.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.router1.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
# Namespace 2 Configuration
**.hostC.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.hostC.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
**.hostD.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.hostD.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
**.router2.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.router2.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
# Gateway Router Configuration
**.gatewayRouter.ipv4.configurator.typename = “Ipv4NetworkConfigurator”
**.gatewayRouter.ipv4.configurator.config = xmldoc(“NamespaceConfig.xml”)
Configure an XML file that stipulates the IP addressing scheme for each namespace and the routing information.
Example IP Address Configuration File (NamespaceConfig.xml):
<?xml version=”1.0″?>
<config>
<!– Namespace 1 –>
<interface hosts=”hostA” address=”192.168.1.1″ netmask=”255.255.255.0″/>
<interface hosts=”hostB” address=”192.168.1.2″ netmask=”255.255.255.0″/>
<interface hosts=”router1″ address=”192.168.1.254″ netmask=”255.255.255.0″/>
<!– Routing Table for Namespace 1 –>
<route hosts=”hostA,hostB” destination=”0.0.0.0″ netmask=”0.0.0.0″ gateway=”192.168.1.254″/>
<!– Namespace 2 –>
<interface hosts=”hostC” address=”192.168.2.1″ netmask=”255.255.255.0″/>
<interface hosts=”hostD” address=”192.168.2.2″ netmask=”255.255.255.0″/>
<interface hosts=”router2″ address=”192.168.2.254″ netmask=”255.255.255.0″/>
<!– Routing Table for Namespace 2 –>
<route hosts=”hostC,hostD” destination=”0.0.0.0″ netmask=”0.0.0.0″ gateway=”192.168.2.254″/>
<!– Gateway Router Configuration –>
<interface hosts=”gatewayRouter” address=”192.168.1.253″ netmask=”255.255.255.0″/>
<interface hosts=”gatewayRouter” address=”192.168.2.253″ netmask=”255.255.255.0″/>
<route hosts=”gatewayRouter” destination=”192.168.1.0″ netmask=”255.255.255.0″ gateway=”192.168.1.253″/>
<route hosts=”gatewayRouter” destination=”192.168.2.0″ netmask=”255.255.255.0″ gateway=”192.168.2.253″/>
</config>
Run the simulation and monitor the actions of the network. Nodes inside the same namespace should be able to communicate freely, while communication amongst various namespaces should be controlled by the gateway router.
Example Configuration to Test Communication:
network = NamespaceNetwork
**.hostA.numApps = 1
**.hostA.app[0].typename = “PingApp”
**.hostA.app[0].destAddr = “192.168.1.2” # Ping hostB within the same namespace
**.hostA.app[0].startTime = 1s
**.hostA.app[0].count = 10
**.hostC.numApps = 1
**.hostC.app[0].typename = “PingApp”
**.hostC.app[0].destAddr = “192.168.2.2” # Ping hostD within the same namespace
**.hostC.app[0].startTime = 1s
**.hostC.app[0].count = 10
# Optionally, test inter-namespace communication through the gateway
**.hostA.app[1].typename = “PingApp”
**.hostA.app[1].destAddr = “192.168.2.1” # Ping hostC in a different namespace
**.hostA.app[1].startTime = 2s
**.hostA.app[1].count = 10
After running the simulation, evaluate that nodes can communicate within their namespaces. Examine inter-namespace communication and approve that it works only over and done with the configured gateway router.
You can extend the network to attach additional namespaces by including more routers, switches, and hosts. Update the NED and XML configuration files based on the new namespaces.
Example: Adding a Third Namespace:
// Add another set of hosts, switches, and routers to represent a new namespace
submodules:
router3: Router {
@display(“p=500,200”);
}
hostE: StandardHost {
@display(“p=450,100”);
}
hostF: StandardHost {
@display(“p=550,100”);
}
switch3: EtherSwitch {
@display(“p=500,150”);
}
connections allowunconnected:
hostE.ethg++ <–> ethernetLine <–> switch3.ethg++;
hostF.ethg++ <–> ethernetLine <–> switch3.ethg++;
switch3.ethg++ <–> ethernetLine <–> router3.ethg++;
router3.ethg++ <–> ethernetLine <–> gatewayRouter.ethg++; // Connect to gateway for inter-namespace communication
We collected the essential details regarding the implementation of network namespaces in OMNeT++ by offering the step-by-step demonstration to help you. If you need any additional information about this namespaces, we can also offer it through another simulation.