Я использую OMNet ++ для имитации беспроводной сети. Код ниже:OMNet ++ для отправки пакета с одного узла на другой узел и для записи отправленных пакетов и потребления энергии в виде графика
NED FILE
import inet.common.figures.DelegateSignalConfigurator;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.inet.INetworkNode;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.visualizer.integrated.IntegratedCanvasVisualizer;
network WirelessA
{
parameters:
string hostType = default("WirelessHost");
string mediumType = default("IdealRadioMedium");
@display("bgb=2500,2500;bgg=100,1,grey95");
@figure[title](type=label; pos=0,-1; anchor=sw; color=darkblue);
@figure[rcvdPkText](type=indicatorText; pos=900,50; anchor=w; font=,50; textFormat="Packets Received: %g"; initialValue=0);
//@statistic[rcvdPk](source=hostB_rcvdPk; record=figure(count); targetFigure=rcvdPkText);
//@signal[hostB_rcvdPk];
//@delegatesignal[rcvdPk](source=hostB.udpApp[0].rcvdPk; target=hostB_rcvdPk);
submodules:
visualizer: IntegratedCanvasVisualizer {
@display("p=2400,50");
}
configurator: IPv4NetworkConfigurator {
@display("p=2400,250");
}
radioMedium: <mediumType> like IRadioMedium {
@display("p=2400,450");
}
figureHelper: DelegateSignalConfigurator {
@display("p=2400,650");
}
BaseStation: <hostType> like INetworkNode {
@display("p=1200,1200;i=device/antennatower");
}
SubStationA: <hostType> like INetworkNode {
@display("p=600,650;i=device/receiverdish");
}
SubStationB: <hostType> like INetworkNode {
@display("p=1750,600;i=device/receiverdish");
}
SubStationC: <hostType> like INetworkNode {
@display("p=1700,1700;i=device/receiverdish");
}
SubStationD: <hostType> like INetworkNode {
@display("p=650,1750;i=device/receiverdish");
}
SensorNodeA1: <hostType> like INetworkNode {
@display("p=875,900;i=device/device");
}
SensorNodeA2: <hostType> like INetworkNode {
@display("p=425,975;i=device/device");
}
SensorNodeA3: <hostType> like INetworkNode {
@display("p=225,625;i=device/device");
}
SensorNodeA4: <hostType> like INetworkNode {
@display("p=475,275;i=device/device");
}
SensorNodeA5: <hostType> like INetworkNode {
@display("p=875,450;i=device/device");
}
SensorNodeB1: <hostType> like INetworkNode {
@display("p=1875,300;i=device/device");
}
SensorNodeB2: <hostType> like INetworkNode {
@display("p=1450,425;i=device/device");
}
SensorNodeB3: <hostType> like INetworkNode {
@display("p=1475,850;i=device/device");
}
SensorNodeB4: <hostType> like INetworkNode {
@display("p=1925,925;i=device/device");
}
SensorNodeB5: <hostType> like INetworkNode {
@display("p=2100,575;i=device/device");
}
SensorNodeC1: <hostType> like INetworkNode {
@display("p=1425,1950;i=device/device");
}
SensorNodeC2: <hostType> like INetworkNode {
@display("p=1450,1500;i=device/device");
}
SensorNodeC3: <hostType> like INetworkNode {
@display("p=1875,2075;i=device/device");
}
SensorNodeC4: <hostType> like INetworkNode {
@display("p=2100,1750;i=device/device");
}
SensorNodeC5: <hostType> like INetworkNode {
@display("p=1900,1400;i=device/device");
}
SensorNodeD1: <hostType> like INetworkNode {
@display("p=800,2075;i=device/device");
}
SensorNodeD2: <hostType> like INetworkNode {
@display("p=1000,1700;i=device/device");
}
SensorNodeD3: <hostType> like INetworkNode {
@display("p=650,1450;i=device/device");
}
SensorNodeD4: <hostType> like INetworkNode {
@display("p=350,2050;i=device/device");
}
SensorNodeD5: <hostType> like INetworkNode {
@display("p=275,1625;i=device/device");
}
}
INI FILE
[Config Wireless01]
description = Militart Based WSN Model
network = WirelessA
sim-time-limit = 5s
*.BaseStation.networkLayer.arpType = "GlobalARP"
*.SubStation*.networkLayer.arpType = "GlobalARP"
*.SensorNode**.networkLayer.arpType = "GlobalARP"
*.BaseStation.wlan[0].typename = "WirelessNic"
*.BaseStation.wlan[0].radioType = "IdealRadio"
*.BaseStation.wlan[0].macType = "CsmaCaMac"
*.BaseStation.wlan[0].mac.useAck = true
#*.BaseStation.wlan[0].mac.fullDuplex = false
*.BaseStation.wlan[0].radio.transmitter.communicationRange = 1300m
*.BaseStation.wlan[0].radio.receiver.ignoreInterference = true
*.BaseStation.wlan[0].radio.displayCommunicationRange = true
*.BaseStation.**.bitrate = 10Mbps
*.BaseStation.wlan[0].radio.energyConsumerType = "StateBasedEnergyConsumer"
*.BaseStation.wlan[0].radio.energyConsumer.offPowerConsumption = -1mW
*.BaseStation.wlan[0].radio.energyConsumer.sleepPowerConsumption = 0mW
*.BaseStation.wlan[0].radio.energyConsumer.switchingPowerConsumption = 1mW
*.BaseStation.wlan[0].radio.energyConsumer.receiverIdlePowerConsumption = 2mW
*.BaseStation.wlan[0].radio.energyConsumer.receiverBusyPowerConsumption = 5mW
*.BaseStation.wlan[0].radio.energyConsumer.receiverReceivingPowerConsumption = 10mW
*.BaseStation.wlan[0].radio.energyConsumer.transmitterIdlePowerConsumption = 2mW
*.BaseStation.wlan[0].radio.energyConsumer.transmitterTransmittingPowerConsumption = 100mW
*.BaseStation.energyStorageType = "IdealEnergyStorage"
*.SubStation*.wlan[0].typename = "WirelessNic"
*.SubStation*.wlan[0].radioType = "IdealRadio"
*.SubStation*.wlan[0].macType = "CsmaCaMac"
*.SubStation*.wlan[0].mac.useAck = true
#*.SubStation*.wlan[0].mac.fullDuplex = true
*.SubStation*.wlan[0].radio.transmitter.communicationRange = 600m
*.SubStation*.wlan[0].radio.receiver.ignoreInterference = true
*.SubStation*.wlan[0].radio.displayCommunicationRange = true
*.SubStation*.**.bitrate = 5Mbps
*.SubStation*.wlan[0].radio.energyConsumerType = "StateBasedEnergyConsumer"
*.SubStation*.wlan[0].radio.energyConsumer.offPowerConsumption = -1mW
*.SubStation*.wlan[0].radio.energyConsumer.sleepPowerConsumption = 0mW
*.SubStation*.wlan[0].radio.energyConsumer.switchingPowerConsumption = 1mW
*.SubStation*.wlan[0].radio.energyConsumer.receiverIdlePowerConsumption = 2mW
*.SubStation*.wlan[0].radio.energyConsumer.receiverBusyPowerConsumption = 5mW
*.SubStation*.wlan[0].radio.energyConsumer.receiverReceivingPowerConsumption = 10mW
*.SubStation*.wlan[0].radio.energyConsumer.transmitterIdlePowerConsumption = 2mW
*.SubStation*.wlan[0].radio.energyConsumer.transmitterTransmittingPowerConsumption = 100mW
*.SubStation*.energyStorageType = "IdealEnergyStorage"
*.SensorNode**.wlan[0].typename = "WirelessNic"
*.SensorNode**.wlan[0].radioType = "IdealRadio"
*.SensorNode**.wlan[0].macType = "CsmaCaMac"
*.SensorNode**.wlan[0].mac.useAck = true
#*.SensorNode**.wlan[0].mac.fullDuplex = true
*.SensorNode**.wlan[0].radio.transmitter.communicationRange = 250m
*.SensorNode**.wlan[0].radio.displayCommunicationRange = true
*.SensorNode**.wlan[0].radio.receiver.ignoreInterference = true
*.SensorNode**.**.bitrate = 1Mbps
*.SensorNode**.wlan[0].radio.energyConsumerType = "StateBasedEnergyConsumer"
*.SensorNode**.wlan[0].radio.energyConsumer.offPowerConsumption = -1mW
*.SensorNode**.wlan[0].radio.energyConsumer.sleepPowerConsumption = 0mW
*.SensorNode**.wlan[0].radio.energyConsumer.switchingPowerConsumption = 1mW
*.SensorNode**.wlan[0].radio.energyConsumer.receiverIdlePowerConsumption = 2mW
*.SensorNode**.wlan[0].radio.energyConsumer.receiverBusyPowerConsumption = 5mW
*.SensorNode**.wlan[0].radio.energyConsumer.receiverReceivingPowerConsumption = 10mW
*.SensorNode**.wlan[0].radio.energyConsumer.transmitterIdlePowerConsumption = 2mW
*.SensorNode**.wlan[0].radio.energyConsumer.transmitterTransmittingPowerConsumption = 100mW
*.SensorNode**.energyStorageType = "IdealEnergyStorage"
*.configurator.addStaticRoutes = false
*.hostType = "AODVRouter"
*.visualizer.dataLinkVisualizer.packetNameFilter = "AODV*"
*.visualizer.mediumVisualizer.displaySignals = true
*.SensorNodeA1.numUdpApps = 1
*.SensorNodeA1.udpApp[0].typename = "UDPBasicApp"
*.SensorNodeA1.udpApp[0].destAddresses = "SubStationA"
*.SensorNodeA1.udpApp[0].destPort = 5000
*.SensorNodeA1.udpApp[0].messageLength = 1000B
*.SensorNodeA1.udpApp[0].sendInterval = exponential(12ms)
*.SensorNodeA1.udpApp[0].packetName = "UDPData"
*.SubStationA.numUdpApps = 1
*.SubStationA.udpApp[0].typename = "UDPSink"
*.SubStationA.udpApp[0].localPort = 5000
Здесь сеть становится создана, но когда я пытаюсь отправить пакет из SensorNodeA1 в SubStationA, во время моделирования пакет отправляется из SensorNodeA1 ко всем узлам. Что мне делать, чтобы отправить пакет с одного узла на другой узел? Также я хочу записать, а затем нарисовать график пакетов, отправленных с течением времени, и потребление энергии каждым узлом. Я все еще новичок в OMNet ++, поэтому, если кто-то может мне помочь, это будет полезно