Reputation: 21
I am building a simulation which is to simulate IP network. In simple I am using two host nodes connected with a router. I used FlatNetworkConfigurator to assign IP. whereas my other two hosts are "EtherHost" as shown in ned file below
package swtichtest.simulations;
import swtichtest.Txc;
import inet.nodes.inet.Router;
import inet.nodes.inet.StandardHost;
import inet.nodes.ethernet.EtherHost;
import inet.nodes.ethernet.EtherSwitch;
import ned.DatarateChannel;
import inet.networklayer.autorouting.ipv4.FlatNetworkConfigurator;
channel cable extends DatarateChannel
{
parameters:
delay = 0.1us;
datarate = 100Mbps;
}
network Tictoc
{
@display("bgb=539,141");
submodules:
tic: EtherHost {
@display("p=291,114");
}
toc: EtherHost {
@display("p=401,33");
}
Rout: Router {
@display("is=s;p=173,25");
}
configurator: FlatNetworkConfigurator {
@display("p=22,25");
}
connections:
Rout.ethg++ <--> cable <--> tic.ethg;
Rout.ethg++ <--> cable <--> toc.ethg;
}
But my question is that where I should add my logic to generate packets. If I change the my tic and toc inherited from my simple moudule then how could I generate IP packets?
Upvotes: 1
Views: 1143
Reputation: 6681
You are a bit confused here. EtherHost can be used to generate RAW ethernet frames, so no network and transport layer protocols are present in them. On the other hand routers require IP data inside the frames.
You MUST use StandardHost if you need TCP/IP traffic. Of course StandardHosts also have ethernet interfaces so you can connect those interfaces with the cable. Just forget about EtherHost if you need IP.
Upvotes: 2