NED File examples/ethernet/lans/Networks.ned

Name Description
MixedLAN (network)

Sample Ethernet LAN containing eight hosts, a switch and a bus.

TwoHosts (network)

Sample Ethernet LAN: two hosts directly connected to each other via twisted pair.

SwitchedLAN (network)

Sample Ethernet LAN: four hosts connected to a switch.

HubLAN (network)

Sample Ethernet LAN: four hosts connected by a hub.

BusLAN (network)

Sample Ethernet LAN: four hosts on a bus.

ethernetline (channel) (no description)
SwitchedDuplexLAN (network) (no description)

Source code:

//
// Copyright (C) 2003 CTIE, Monash University
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//



package inet.examples.ethernet.lans;

import inet.linklayer.ethernet.EtherBus;
import inet.linklayer.ethernet.EtherHub;
import inet.nodes.ethernet.EtherHost;
import inet.nodes.ethernet.EtherHost2;
import inet.nodes.ethernet.EtherSwitch;
import inet.nodes.ethernet.EtherSwitch2;
import inet.world.ChannelInstaller;
import ned.DatarateChannel;


//
// Sample Ethernet LAN containing eight hosts, a switch and a bus.
//
network MixedLAN
{
    submodules:
        channelInstaller: ChannelInstaller {
            parameters:
                channelClass = "ThruputMeteringChannel";
                channelAttrs = "format=#N";
                @display("p=75,52");
        }
        bus: EtherBus {
            parameters:
                positions = "10 20 24 35 40 48";
                propagationSpeed = 2e8 mps; // 1us = 200m
                @display("p=277,182;b=424,6;o=#408060");
            gates:
                ethg[6];
        }
        busHostA: EtherHost {
            parameters:
                @display("p=122,118");
        }
        busHostB: EtherHost {
            parameters:
                @display("p=210,118");
        }
        busHostC: EtherHost {
            parameters:
                @display("p=338,238");
        }
        busHostD: EtherHost {
            parameters:
                @display("p=426,238");
        }
        switchHostA: EtherHost {
            parameters:
                @display("p=82,300");
        }
        switchHostB: EtherHost {
            parameters:
                @display("p=162,300");
        }
        switchHostC: EtherHost {
            parameters:
                @display("p=234,300");
        }
        switchHostD: EtherHost {
            parameters:
                @display("p=306,300");
        }
        switch: EtherSwitch {
            parameters:
                @display("p=194,236");
            gates:
                ethg[5];
        }
        hubHostA: EtherHost {
            parameters:
                @display("p=297,55");
        }
        hubHostB: EtherHost {
            parameters:
                @display("p=365,55");
        }
        hubHostC: EtherHost {
            parameters:
                @display("p=430,55");
        }
        hub: EtherHub {
            parameters:
                @display("p=362,132");
            gates:
                ethg[4];
        }
    connections:
        bus.ethg[0] <--> busHostA.ethg;
        bus.ethg[1] <--> busHostB.ethg;
        bus.ethg[2] <--> switch.ethg[4];
        bus.ethg[3] <--> busHostC.ethg;
        bus.ethg[4] <--> hub.ethg[3];
        bus.ethg[5] <--> busHostD.ethg;

        switch.ethg[0] <--> {  delay = 0.1us; } <--> switchHostA.ethg;
        switch.ethg[1] <--> {  delay = 0.1us; } <--> switchHostB.ethg;
        switch.ethg[2] <--> {  delay = 0.1us; } <--> switchHostC.ethg;
        switch.ethg[3] <--> {  delay = 0.1us; } <--> switchHostD.ethg;

        hub.ethg[0] <--> {  delay = 0.1us; } <--> hubHostA.ethg;
        hub.ethg[1] <--> {  delay = 0.3us; } <--> hubHostB.ethg;
        hub.ethg[2] <--> {  delay = 0.2us; } <--> hubHostC.ethg;
}


//
// Sample Ethernet LAN: two hosts directly connected to each other
// via twisted pair.
//
network TwoHosts
{
    submodules:
        hostA: EtherHost {
            parameters:
                @display("p=60,160");
        }
        hostB: EtherHost {
            parameters:
                @display("p=200,140");
        }
    connections:
        hostA.ethg <--> {  delay = 0.5us; } <--> hostB.ethg;
}


//
// Sample Ethernet LAN: four hosts connected to a switch.
//
network SwitchedLAN
{
    types:
        channel C extends DatarateChannel
        {
            delay = 0.1us;
        }
    submodules:
        hostA: EtherHost {
            parameters:
                @display("p=161,55");
        }
        hostB: EtherHost {
            parameters:
                @display("p=253,125");
        }
        hostC: EtherHost {
            parameters:
                @display("p=158,199");
        }
        hostD: EtherHost {
            parameters:
                @display("p=59,127");
        }
        switch: EtherSwitch {
            parameters:
                @display("p=162,124");
            gates:
                ethg[4];
        }
    connections:
        switch.ethg[0] <--> C <--> hostA.ethg;
        switch.ethg[1] <--> C <--> hostB.ethg;
        switch.ethg[2] <--> C <--> hostC.ethg;
        switch.ethg[3] <--> C <--> hostD.ethg;
}


//
// Sample Ethernet LAN: four hosts connected by a hub.
//
network HubLAN
{
    submodules:
        hostA: EtherHost {
            parameters:
                @display("p=161,55");
        }
        hostB: EtherHost {
            parameters:
                @display("p=253,125");
        }
        hostC: EtherHost {
            parameters:
                @display("p=158,199");
        }
        hostD: EtherHost {
            parameters:
                @display("p=59,127");
        }
        hub: EtherHub {
            parameters:
                @display("p=162,124");
            gates:
                ethg[4];
        }
    connections:
        hub.ethg[0] <--> {  delay = 0.1us; } <--> hostA.ethg;
        hub.ethg[1] <--> {  delay = 0.3us; } <--> hostB.ethg;
        hub.ethg[2] <--> {  delay = 0.4us; } <--> hostC.ethg;
        hub.ethg[3] <--> {  delay = 0.2us; } <--> hostD.ethg;
}


//
// Sample Ethernet LAN: four hosts on a bus.
//
network BusLAN
{
    submodules:
        hostA: EtherHost {
            parameters:
                @display("p=100,150");
        }
        hostB: EtherHost {
            parameters:
                @display("p=200,150");
        }
        hostC: EtherHost {
            parameters:
                @display("p=300,150");
        }
        hostD: EtherHost {
            parameters:
                @display("p=400,150");
        }
        bus: EtherBus {
            parameters:
                positions = "0 10 20 30";
                propagationSpeed = 2e8 mps;
                @display("p=250,100;b=400,6;o=#408060");
            gates:
                ethg[4];
        }
    connections:
        bus.ethg[0] <--> hostA.ethg;
        bus.ethg[1] <--> hostB.ethg;
        bus.ethg[2] <--> hostC.ethg;
        bus.ethg[3] <--> hostD.ethg;
}

channel ethernetline extends DatarateChannel
{
    parameters:
        delay = 0.1us;
        datarate = 10Mbps;
}

network SwitchedDuplexLAN
{
    submodules:
        hostA: EtherHost2 {
            parameters:
                @display("p=161,55");
        }
        hostB: EtherHost2 {
            parameters:
                @display("p=253,125");
        }
        hostC: EtherHost2 {
            parameters:
                @display("p=158,199");
        }
        hostD: EtherHost2 {
            parameters:
                @display("p=59,127");
        }
        switch: EtherSwitch2 {
            parameters:
                @display("p=162,124");
            gates:
                ethg[4];
        }
    connections:
        switch.ethg[0] <--> ethernetline <--> hostA.ethg;
        switch.ethg[1] <--> ethernetline <--> hostB.ethg;
        switch.ethg[2] <--> ethernetline <--> hostC.ethg;
        switch.ethg[3] <--> ethernetline <--> hostD.ethg;
}