首页 > 解决方案 > 如何实现复合模块向量(包括路由器、主机、移动模块等)之间的路由功能?

问题描述

如何实现复合模块向量(包括路由器、主机、移动模块等)之间的路由功能?例如,如何连接内部和外部复合模块向量?网络中间的复合模块如何转发数据?

1.我在 Ubuntu 18.04 上使用 omnet++5.4.1 和 inet4.0

  1. 我正在使用卫星模拟模块-os3。这里是卫星模块代码和 SatSGP4 网络代码,omnetpp.ini 代码。

package os3.base;

//import inet.base.NotificationBoard;
import inet.mobility.contract.IMobility;
import inet.networklayer.ipv4.RoutingTableRecorder;
import inet.node.inet.Router;
import inet.node.inet.StandardHost;
import os3.mobility.Norad;
import os3.mobility.SatSGP4Mobility;
import inet.node.ethernet.Eth1G;

module Satellite
{
    parameters:
        @nodes();
        @node; //because of MobilityBase initialization
        string satelliteName = default(""); // Parameter for satellite name
        string mobilityType = default("SatSGP4Mobility"); // Define mobility module
        // Transmit Power of satellite (7dBW as example for CospasSarsat system)
        double transmitPower @unit(dBW) @display("i=device/satellite;bgb=324,226") = default(7dBW); // Symbol
        @display("t=$satelliteName;bgb=688,367");
    gates:
        //input radioIn; // Input gate
        //output radioOut; // Output gate
        inout ethg[];

    submodules:
        mobility: <mobilityType> like IMobility { // Module for mobility (parent class -> BasicMobility), BasicMobility -> IMobility
            @display("p=57,109");
        }
        //mobility : SatSGP4Mobility {
        //     parameters:
        //     @display("p=194,103");
        //}
        //        notificationBoard: NotificationBoard { // Module for event notification
        //            parameters:
        //                @display("p=221,94");
        //        }
        NoradModule: Norad { // Module for transformation between omnet and libNorad
            parameters:
                @display("p=51,36");
        }
        host: StandardHost {
            @display("p=204,101");
        }
        router: Router {
            @display("p=204,233");
        }
    connections allowunconnected:
        host.ethg++ <--> Eth1G <--> router.ethg++;              
        // towards other areas 
        router.ethg++ <--> ethg++;
}


package os3.examples.SatSGP4;

import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
import os3.base.Satellite;
import os3.base.MissionControlCenter;
//import inet.world.radio.ChannelControl;
import inet.physicallayer.common.packetlevel.RadioMedium;
import os3.base.CNI_OS3;
import inet.node.ethernet.Eth100M;
//
// Network SatSGP4 enables satellite movement on worldmap
//
network SatSGP4
{
    parameters:
        int numOfSats; // Number of satellites
        int numOfMCCs; // Number of Mission Control Centers

        @display("bgi=background/background_earth,s;bgb=2160,1080");

    submodules:
        satellite[numOfSats]: Satellite {
            parameters:
                @display("p=116.315,384.11;r=10,,#707070;i=device/satellite_l");
        }
        MCC[numOfMCCs]: MissionControlCenter {
            parameters:
                @display("p=300.255,292.13998;i=misc/building;r=10,,black");
        }
        channelcontrol: RadioMedium {
            parameters:
                //numChannels = 2;
                @display("p=300.255,64.92;i=misc/sun");
        }
        cni_os3: CNI_OS3 {
            @display("p=80,70,i;i=old/bluebox");
        }
        configurator: Ipv4NetworkConfigurator {
            @display("p=562.64,67.625");
        }
    connections allowunconnected:
        satellite[0].ethg++ <--> Eth100M <--> satellite[1].ethg++;      
        satellite[1].ethg++ <--> Eth100M <--> satellite[2].ethg++;
}

[Config SatSGP4]
network = SatSGP4

SatSGP4.satellite[*].mobilityType = "SatSGP4Mobility"

**.constraintAreaMinX = 0m
**.constraintAreaMaxX = 2160m

**.constraintAreaMinY = 0m
**.constraintAreaMaxY = 1080m

**.constraintAreaMinZ = 0m
**.constraintAreaMaxZ = 0m
#-----------------------------radiomedium seetings---------
**.channelcontrol.propagation.typename ="ConstantTimePropagation"
**.channelcontrol.analogModel.typename ="ScalarAnalogModel"
**.channelcontrol.pathLoss.typename ="FreeSpacePathLoss"
#-------------------------------nic setting ---------------------

# tcp apps
**.satellite[0].host.numApps = 1
**.satellite[0].host.app[*].typename = "TcpSessionApp"
**.satellite[0].host.app[0].active = true
**.satellite[0].host.app[0].localAddress = ""
**.satellite[0].host.app[0].localPort = -1
**.satellite[0].host.app[0].connectAddress = "SatSGP4.satellite[2].host"
**.satellite[0].host.app[0].connectPort = 1000
**.satellite[0].host.app[0].tOpen = exponential(0.1s)
**.satellite[0].host.app[0].tSend = 0s
**.satellite[0].host.app[0].sendBytes = 1MiB
**.satellite[0].host.app[0].sendScript = ""
**.satellite[0].host.app[0].tClose = 0s

**.satellite[2].host.numApps = 1
**.satellite[2].host.app[*].typename = "TcpSinkApp"
**.satellite[2].host.app[0].localAddress = ""
**.satellite[2].host.app[0].localPort = 1000

# NIC configuration
**.ppp[*].queue.typename = "DropTailQueue" # in routers
**.ppp[*].queue.frameCapacity = 10  # in routers


[General]
# location of NED files
ned-path = ../../../inet/src;../../src/os3;.;
# location of images for GUI
image-path = ../../images/os3
#
sim-time-limit = 1500s

# Network parameters
**.updateInterval = 10s   # Interval to update the satellite positions on the map
**.numOfSats = 3          # Number of satellites used in simulation. ATTENTION! Must be smaller or equal to number of satellites in choosen TLEfile

# Parameters for UserConfig
**.userConfig.frequency = 1e9Hz
**.userConfig.min_snr = 0dBHz

#
# Parameters for WebServiceControl
#
# Insert you own API Key. You can register at http://www.worldweatheronline.com/free-weather-feed.aspx
**.webServiceControl.apiKeyWeather = ""
# Insert your own username from http://www.geonames.org/login
**.webServiceControl.usernameAltitude = ""
# (default = 100) Maximum number of saved altitude values. Be careful when changing!
**.webServiceControl.altitudeCacheThreshold = 100
# (default = 10) Maximum number of saved TLE data strings. Be careful when changing!
**.webServiceControl.tleCacheThreshold = 10
# (default = 10) Maximum number of saved weather data strings. Be careful when changing!
**.webServiceControl.weatherCacheThreshold = 10

#
# Parameters for WeatherControl
#
# (default = -1 means using live weather data) Precip per hour (unit mm/(m2*h))
**.weatherControl.defaultPrecipPerHour = -1

#
# Parameters for Norad
#
# Provide the filename of the TLEs. Used by Webservice if GUI not used,
# must fit the names from http://celestrak.com/NORAD/elements/xxx.txt
*.satellite[*].NoradModule.TLEfile = "gps-ops.txt"

#
# Parameters for Calculation
#
# Provide the name of the Table for the Rain parameters. DO NOT CHANGE!
**.calculation.rainTableFile = "../../data/TablespecRain.csv"

#
# Parameters for Satellite
#
# (default = 7dBW) Transmit power of satellites (Can be choosen individually for each satellite, see MCCs for example)
*.satellite[*].transmitPower = 10dBW
# default = "", satelliteName is only used if a specific satellite from a TLE file should be used instead of the first numOfSats.
#*.satellite[0].satelliteName = "GPS BIIA-10 (PRN 32)"

#
# Parameters for Channelcontrol (INET module) 
#
# Variable. Maximum transmit Power of a Base Station found in Germany (Usingen).
# Default(20mW) Maximum sending power used for this network (in mW)
*.channelcontrol.pMax = 100000W

#----------------------------------------------------
# Mission Control Centers all over the world
#----------------------------------------------------

**.numOfMCCs = 4

# Algier
SatSGP4.MCC[0].mobility.latitude = 36.46
SatSGP4.MCC[0].mobility.longitude = 3.03
SatSGP4.MCC[0].cityName = "Algier"

# Ourgla
SatSGP4.MCC[1].mobility.latitude = 31.57
SatSGP4.MCC[1].mobility.longitude = 5.20
SatSGP4.MCC[1].cityName = "Ourgla"

# Parana, Argentinia
SatSGP4.MCC[2].mobility.latitude = -31.43
SatSGP4.MCC[2].mobility.longitude = -60.30
SatSGP4.MCC[2].cityName = "Parana"

# Rio Grande
SatSGP4.MCC[3].mobility.latitude = -53.47
SatSGP4.MCC[3].mobility.longitude = -67.42
SatSGP4.MCC[3].cityName = "Rio Grande"

我希望卫星 [0] 的主机将 tcp 数据传输到卫星 [2] 的主机,但它不能这样做。当我运行 ini 文件时,在卫星 [0] 中,主机发送 arpREQ 到路由器,路由器接收 arpREQ并向主机发送arpReply,但是当主机再次向路由器发送SYN时,路由器发送ICMP-error-#3-type3-code0。链接错误或设置ini错误或其他错误?提前谢谢您的帮助。

标签: omnet++inet

解决方案


推荐阅读