NED File src/nodes/StandardVlanHost.ned

Name Description
StandardVlanHost (compound module)

IP host with TCP, UDP layers and applications.

Source code:

//
// Copyright (C) 2004 Andras Varga
// Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//


package Vlans.nodes;

import inet.applications.pingapp.PingApp;
import inet.applications.tcpapp.TCPApp;
import inet.applications.udpapp.UDPApp;
import inet.applications.sctpapp.SCTPApp;   //I.R.
import inet.base.NotificationBoard;
import inet.linklayer.ethernet.EthernetInterface;
import inet.linklayer.ppp.PPPInterface;
import inet.linklayer.ext.ExtInterface; //I.R.
import inet.networklayer.common.InterfaceTable;
import inet.networklayer.ipv4.RoutingTable;
import inet.nodes.inet.NetworkLayer;
import inet.transport.tcp.TCP;
import inet.transport.udp.UDP;
import inet.transport.sctp.SCTP;    //I.R.
import inet.util.TCPDump;   //I.R.
import inet.util.NAMTraceWriter;

import Vlans.linklayer.*;
import Vlans.networklayer.*;
import Vlans.linklayer.EtherVlanInterface;


//
// \IP host with TCP, UDP layers and applications.
//
module StandardVlanHost
{
    parameters:
        @node();
        int numTcpApps = default(0);
        int numUdpApps = default(0);
        int numSctpApps = default(0);   //I.R.
        string tcpAppType = default("n/a");
        string udpAppType = default("n/a");
        string sctpAppType = default("n/a");    //I.R.
        bool IPForward = default(false);
        int namid = default(-1);
        string routingFile = default("");
        @display("i=device/pc2");
    gates:
        inout pppg[];
        inout ethg[];
        inout extg[];
    submodules:
        namTrace: NAMTraceWriter {
            parameters:
                namid = namid;
                @display("p=60,310");
        }
        notificationBoard: NotificationBoard {
            parameters:
                @display("p=60,70");
        }
        interfaceTable: InterfaceTable {
            parameters:
                @display("p=60,150");
        }
        routingTable: RoutingTable {
            parameters:
                IPForward = IPForward;
                routerId = "";
                routingFile = routingFile;
                @display("p=60,230");
        }
        tcpApp[numTcpApps]: <tcpAppType> like TCPApp {
            parameters:
                @display("p=163,53");
        }
        tcp: TCP {
            parameters:
                @display("p=163,154");
        }
        udpApp[numUdpApps]: <udpAppType> like UDPApp {
            parameters:
                @display("p=272,67");
        }
        udp: UDP {
            parameters:
                @display("p=272,154");
        }
        sctpApp[numSctpApps]: <sctpAppType> like SCTPApp {  //I.R.
            parameters:
                @display("p=385,85");
        }
        sctp: SCTP {    //I.R.
            @display("p=382,170;i=block/wheelbarrow");
        }
        pingApp: PingApp {
            parameters:
                @display("p=376,241");
        }
        networkLayer_vlans: NetworkLayerVlans {
            parameters:
                proxyARP = false;
                @display("p=248,247;q=queue");
            gates:
                ifIn[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];   //I.R.
                ifOut[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];
        }
        ppp[sizeof(pppg)]: PPPInterface {
            parameters:
                @display("p=124,390,row,90;q=txQueue");
        }
        eth[sizeof(ethg)]: EtherVlanInterface {
            parameters:
                @display("p=254,390,row,90;q=txQueue");
        }
        ext[sizeof(extg)]: ExtInterface {   //I.R.
            parameters:
                @display("p=399,390,row,90;q=txQueue;i=block/ifcard");
        }
        tcpdump: TCPDump {  //I.R.
            parameters:
                @display("p=254,310;i=abstract/cache_s");
            gates:
                ifIn[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];
                in2[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];
                ifOut[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];
                out2[sizeof(pppg)+sizeof(ethg)+sizeof(extg)];
        }
    connections allowunconnected:
        for i=0..numTcpApps-1 {
            tcpApp[i].tcpOut --> tcp.appIn++;
            tcpApp[i].tcpIn <-- tcp.appOut++;
        }

        tcp.ipOut --> networkLayer_vlans.tcpIn;
        tcp.ipIn <-- networkLayer_vlans.TCPOut;

        for i=0..numUdpApps-1 {
            udpApp[i].udpOut --> udp.appIn++;
            udpApp[i].udpIn <-- udp.appOut++;
        }

        udp.ipOut --> networkLayer_vlans.udpIn;
        udp.ipIn <-- networkLayer_vlans.udpOut;

        for i=0..numSctpApps-1 {
            sctpApp[i].sctpOut --> sctp.from_appl++;
            sctp.to_appl++ --> sctpApp[i].sctpIn;
        }
        sctp.to_ip --> networkLayer_vlans.sctpIn;
        networkLayer_vlans.sctpOut --> sctp.from_ip;

        networkLayer_vlans.pingOut --> pingApp.pingIn;
        networkLayer_vlans.pingIn <-- pingApp.pingOut;

        // connections to network outside
        for i=0..sizeof(pppg)-1 {
            pppg[i] <--> ppp[i].phys;
            ppp[i].netwOut --> tcpdump.ifIn[i]; //I.R.
            tcpdump.out2[i] --> networkLayer_vlans.ifIn[i];
            ppp[i].netwIn <-- tcpdump.ifOut[i];
            tcpdump.in2[i] <-- networkLayer_vlans.ifOut[i];
        }

        for i=0..sizeof(ethg)-1 {
            ethg[i] <--> eth[i].phys;
            eth[i].netwOut --> tcpdump.ifIn[sizeof(pppg)+i];  //I.R.
            tcpdump.out2[sizeof(pppg)+i] --> networkLayer_vlans.ifIn[sizeof(pppg)+i];
            eth[i].netwIn <-- tcpdump.ifOut[sizeof(pppg)+i];
            tcpdump.in2[sizeof(pppg)+i] <-- networkLayer_vlans.ifOut[sizeof(pppg)+i];
        }

        for i=0..sizeof(extg)-1 {
            ext[i].netwOut --> tcpdump.ifIn[sizeof(pppg)+sizeof(ethg)+i];
            tcpdump.out2[sizeof(pppg)+sizeof(ethg)+i] --> networkLayer_vlans.ifIn[sizeof(pppg)+sizeof(ethg)+i];
            ext[i].netwIn <-- tcpdump.ifOut[sizeof(pppg)+sizeof(ethg)+i];
            tcpdump.in2[sizeof(pppg)+sizeof(ethg)+i] <-- networkLayer_vlans.ifOut[sizeof(pppg)+sizeof(ethg)+i];
        }
}