OMNet++: EtherSwitch and EtherHost device configurations and routing. How to?
i am trying to build a network simulation with OMNet++. Problem is i dont know how to configure EtherSwitch and EtherHost devices and give them IP. What is the necessary routing code to rout traffic between switches and routers. IP addresses of the routers's ports must be like table below;
Router Leg IP
1 ------ 1 --- 192.168.1.0/24 1 ------ 4 --- 192.168.4.1 1 ------ 5 --- 192.168.5.1 2 ------ 2 --- 192.168.2.0/24 2 ------ 5 --- 192.168.5.2 2 ------ 6 --- 192.168.6.2 3 ------ 3 --- 192.168.3.0/24 3 ------ 4 --- 192.168.4.3 3 ------ 6 --- 192.168.6.3Here image of the required network:
My NED file:
import inet.nodes.inet.Router;
import inet.nodes.inet.StandardHost;
import ned.DatarateChannel;
import inet.nodes.ethernet.EtherSwitch;
import inet.nodes.ethernet.EtherHost;
import inet.networklayer.autorouting.FlatNetworkConfigurator;
network gyte
{
@display("bgb=457,318");
开发者_如何学JAVA types:
channel geth extends DatarateChannel
{
datarate = 1Gbps;
}
channel hgeth extends DatarateChannel
{
datarate = 512Mbps;
}
submodules:
// Routers
routers[3]: Router {
parameters:
@display("p=208,272,row=id;i=abstract/router");
gates:
pppg[3];
}
// Switches
switches[3]: EtherSwitch {
parameters:
@display("p=179,162,row");
gates:
ethg[3];
}
// Hosts
ehosts[4]: EtherHost {
parameters:
@display("p=384,56,row");
gates:
ethg;
}
// Servers
eservers[2]: EtherHost {
parameters:
@display("i=device/server;p=117,71,row");
gates:
ethg;
}
configurator: FlatNetworkConfigurator {
@display("p=22,25");
}
connections:
ehosts[0].ethg <--> switchs[0].ethg[0];
eservers[0].ethg <--> switchs[0].ethg[1];
ehosts[1].ethg <--> switchs[1].ethg[0];
eservers[1].ethg <--> switchs[1].ethg[1];
switchs[0].ethg[2] <--> routers[0].pppg[0];
switchs[1].ethg[2] <--> routers[1].pppg[0];
routers[0].pppg[1] <--> routers[1].pppg[1];
routers[0].pppg[2] <--> routers[2].pppg[0];
routers[1].pppg[2] <--> routers[2].pppg[1];
routers[2].pppg[2] <--> switchs[2].ethg[0];
switchs[2].ethg[1] <--> ehosts[2].ethg;
switchs[2].ethg[2] <--> ehosts[3].ethg;
}
Switches dont have an IP address (In reality they have in order to administrate the Switch). Switching (Layer 2) is based on MAC addresses. So in the simulation you dont have to configure anything for the Switches.
In order to assign IP addresses to the hosts and routers and add the routes to the routing tables you can use the "flatnetworkconfigurator" module. Simply put it in your NED file. But all IP addresses will be out of one subnet.
Other solution is to use MRT files. There you specify with linux syntax the IP, subnetmask, gateway etc. for each interface.
精彩评论