To implement the User Datagram Protocol (UDP) in OMNeT++ has needs to setup the emulation that the models a network wherever the device interact by UDP protocol. The INET framework in OMNeT++ delivers the complete support for UDP.now we are going to see how to simulate a UDP network using OMNeT++ and INET:
Step-by-Step Implementation:
Make certain we have OMNeT++ and the INET Framework installed.
Generate a new NED file to describe the network topology has contains hosts by the UDP protocol.
Example: UDP Network Topology (UDPNetwork.ned)
package udp;
import inet.node.inet.StandardHost;
import inet.node.inet.Router;
network UDPNetwork
{
parameters:
@display(“bgb=600,400”);
submodules:
host1: StandardHost {
@display(“p=100,200”);
}
host2: StandardHost {
@display(“p=500,200”);
}
router: Router {
@display(“p=300,200”);
}
connections:
host1.ethg++ <–> Eth10M <–> router.ethg++;
host2.ethg++ <–> Eth10M <–> router.ethg++;
}
In this example:
Create an OMNeT++ initialization file to configure the parameters of the simulation.
Example: Configuration File (omnetpp.ini)
network = udp.UDPNetwork
sim-time-limit = 100s
# Visualization
*.visualizer.canvasVisualizer.displayBackground = true
*.visualizer.canvasVisualizer.displayGrid = true
# Host Configuration
*.host*.numUdpApps = 2
*.host1.udpApp[0].typename = “UdpBasicApp”
*.host1.udpApp[0].destAddresses = “host2”
*.host1.udpApp[0].destPort = 5000
*.host1.udpApp[0].messageLength = 1024B
*.host1.udpApp[0].sendInterval = 1s
*.host2.udpApp[0].typename = “UdpSink”
*.host2.udpApp[0].localPort = 5000
# UDP Configuration
*.host*.hasUdp = true
# IP Address Configuration
*.host1.ipv4.config = xmldoc(“host1.xml”)
*.host2.ipv4.config = xmldoc(“host2.xml”)
*.router.ipv4.config = xmldoc(“router.xml”)
Generate XML files to describe the IP address configuration for each host and the router.
Example: IP Configuration File for host1 (host1.xml)
<config>
<interface>
<name>eth0</name>
<address>192.168.1.1</address>
<netmask>255.255.255.0</netmask>
</interface>
<routing>
<route>
<destination>0.0.0.0</destination>
<netmask>0.0.0.0</netmask>
<gateway>192.168.1.254</gateway>
</route>
</routing>
</config>
Example: IP Configuration File for host2 (host2.xml)
<config>
<interface>
<name>eth0</name>
<address>192.168.1.2</address>
<netmask>255.255.255.0</netmask>
</interface>
<routing>
<route>
<destination>0.0.0.0</destination>
<netmask>0.0.0.0</netmask>
<gateway>192.168.1.254</gateway>
</route>
</routing>
</config>
Example: IP Configuration File for router (router.xml)
<config>
<interface>
<name>eth0</name>
<address>192.168.1.254</address>
<netmask>255.255.255.0</netmask>
</interface>
</config>
Here, we demonstrate the complete procedures to execute the UDP that used to communicate with other devices using the UDP protocol that were implemented using the OMNeT++ simulator. Further details regarding the implementation of the User Datagram Protocol in different simulations will be provided. We present the simulation results for your project using the UDP protocol in the OMNeT++ tool for your projects.