2017-02-22 2 views
0

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 파일 여기

[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 

네트워크가 만들어지고 있지만, 내가 SubStationA에 SensorNodeA1에서 패킷을 보내려고 할 때, 시뮬레이션 중에 패킷이 SensorNodeA1에서 모든 노드로 전송됩니다. 한 노드에서 다른 단일 노드로 패킷을 보내려면 어떻게해야합니까? 또한 나는 기록하고 각 노드의 에너지 소비와 시간에 따라 전송 된 패킷 그래프를 그려보고 싶다. 나는 여전히 OMNet ++에 익숙하지 않기 때문에 누군가가 나를 안내 할 수 있다면 도움이 될 것입니다.

답변

1

무선 시나리오에서는 메시지가 무선 매체에서 항상 "브로드 캐스트"되므로 라디오 범위의 모든 수신기로 메시지가 전달됩니다 . 무선 라디오 매체 모델에 따라 간섭 범위에있는 수신기로 이동하여 간섭 수준을 계산할 수도 있습니다. 무선에는 "유니 캐스트"가 없습니다. 동일한 주파수에 있고 변조 등을 알면 모두가 모든 것을 수신 할 수있는 공유 된 매체입니다.

"유니 캐스트"또는 "멀티 캐스트"는 높은 수준, 예. 주소 지정을 통해 목적지 주소 "SubStationA"를 사용하는 것과 같습니다. 패킷을 수신하는 다른 노드의 출력을 확인합니다. 실제로 응용 프로그램 계층에서 수신합니까 아니면 다른 대상 주소로 인해 MAC 계층에서 무시합니까? 다시 말하지만 어떤 종류의 포워딩이나 라우팅 프로토콜이 사용되면 노드는 패킷을 전송할 수 있습니다 ...

통계적 기록에 대해서는이 복잡한 부분에 대한 정보는 OMNeT manual을 확인하십시오.

대부분의 기존 INET 시뮬레이션 모델에는 이미 다양한 통계가 포함되어 있으므로 원하는 통계 (omnetpp.ini 파일을 통해)를 설정하면 생성 된 결과 파일 (유형에 따라 스칼라 또는 벡터)을 체크 아웃 할 수 있습니다 다시 기록하려면 - check the OMNeT simulation manual), 포함 된 분석 도구를 사용하여 데이터를 필터링하고 그래프를 인쇄하십시오.

통계가 아직 포함되지 않은 경우 수동으로 추가 할 수 있습니다. 이는 실제로 복잡하지 않습니다. 귀하의 코드를 기반으로, 당신은 이미 INET 무선 자습서 - 단계 8 - 무선 소비 모델링 (https://omnetpp.org/doc/inet/api-current/tutorials/wireless/step8.html)을 체크 아웃 했으므로 간단히 튜토리얼을 따르고 통계 (https://omnetpp.org/doc/omnetpp/tictoc-tutorial/part4.html)에 대한 TicTocTutorial 부분도 따라 할 것입니다.

관련 문제