【问题标题】:OMNet++: EtherSwitch and EtherHost device configurations and routing. How to?OMNet++:EtherSwitch 和 EtherHost 设备配置和路由。如何?
【发布时间】:2011-05-05 14:40:05
【问题描述】:

我正在尝试使用 OMNet++ 构建网络模拟。问题是我不知道如何配置 EtherSwitch 和 EtherHost 设备并给它们 IP。在交换机和路由器之间路由流量的必要路由代码是什么。路由器端口的IP地址必须如下表;

路由器支路 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.3

这里是所需网络的图片:

我的 NED 文件:

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");
    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;

}

【问题讨论】:

    标签: routing omnet++


    【解决方案1】:

    交换机没有 IP 地址(实际上它们是为了管理交换机而拥有的)。交换(第 2 层)基于 MAC 地址。 所以在模拟中你不必为交换机配置任何东西。

    要为主机和路由器分配 IP 地址并将路由添加到路由表,您可以使用“flatnetworkconfigurator”模块。只需将其放入您的 NED 文件中即可。 但是所有 IP 地址都在一个子网之外。

    其他解决方案是使用 MRT 文件。您可以使用 linux 语法为每个接口指定 IP、子网掩码、网关等。

    【讨论】:

    • 感谢您的回答。但真正的问题是如何将包路由到连接到交换机的主机。在这种情况下,从 router1 路由到 istemci1(host1)。 irt 或 mrt 文件应该是什么样的?
    • 你为什么不简单地使用 flatnetworkConfigurator?它会自动将路由添加到路由器。路由器看不到交换机。它只需要知道哪个子网连接到哪个接口,例如:目标子网 192.168.1.0/24 连接到接口 1 。再说一次,有没有 Switch 也没关系!
    • 再次感谢。这是家庭作业:) 所以我不能使用 flatnetworkConfigurator。顺便说一句,我设法设置了网络,但我仍然感到困惑。我怎样才能从每个主机发送消息。
    • 您可以使用标准主机中的 ping 应用程序,也可以使用其中一个 UDPApps。有如何正确配置INI文件的例子。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    • 2018-01-14
    • 2020-10-05
    • 2014-06-14
    • 2014-05-22
    • 2017-11-23
    • 1970-01-01
    相关资源
    最近更新 更多