title: OMNet++ to send packet from one node to another node and to record packets sent and energy consumption as graph
body: <p>I am using OMNet++ to simulate a wireless network. The code is below:</p>
  
  <p><strong>NED FILE</strong></p>
  
  <pre><code>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: &lt;mediumType&gt; like IRadioMedium {
              @display("p=2400,450");
          }
          figureHelper: DelegateSignalConfigurator {
              @display("p=2400,650");
          }
          BaseStation: &lt;hostType&gt; like INetworkNode {
              @display("p=1200,1200;i=device/antennatower");
          }
          SubStationA: &lt;hostType&gt; like INetworkNode {
              @display("p=600,650;i=device/receiverdish");
          }
          SubStationB: &lt;hostType&gt; like INetworkNode {
              @display("p=1750,600;i=device/receiverdish");
          }
          SubStationC: &lt;hostType&gt; like INetworkNode {
              @display("p=1700,1700;i=device/receiverdish");
          }
          SubStationD: &lt;hostType&gt; like INetworkNode {
              @display("p=650,1750;i=device/receiverdish");
          }
          SensorNodeA1: &lt;hostType&gt; like INetworkNode {
              @display("p=875,900;i=device/device");
          }
          SensorNodeA2: &lt;hostType&gt; like INetworkNode {
              @display("p=425,975;i=device/device");
          }
          SensorNodeA3: &lt;hostType&gt; like INetworkNode {
              @display("p=225,625;i=device/device");
          }
          SensorNodeA4: &lt;hostType&gt; like INetworkNode {
              @display("p=475,275;i=device/device");
          }
          SensorNodeA5: &lt;hostType&gt; like INetworkNode {
              @display("p=875,450;i=device/device");
          }
          SensorNodeB1: &lt;hostType&gt; like INetworkNode {
              @display("p=1875,300;i=device/device");
          }
          SensorNodeB2: &lt;hostType&gt; like INetworkNode {
              @display("p=1450,425;i=device/device");
          }
          SensorNodeB3: &lt;hostType&gt; like INetworkNode {
              @display("p=1475,850;i=device/device");
          }
          SensorNodeB4: &lt;hostType&gt; like INetworkNode {
              @display("p=1925,925;i=device/device");
          }
          SensorNodeB5: &lt;hostType&gt; like INetworkNode {
              @display("p=2100,575;i=device/device");
          }
          SensorNodeC1: &lt;hostType&gt; like INetworkNode {
              @display("p=1425,1950;i=device/device");
          }
          SensorNodeC2: &lt;hostType&gt; like INetworkNode {
              @display("p=1450,1500;i=device/device");
          }
          SensorNodeC3: &lt;hostType&gt; like INetworkNode {
              @display("p=1875,2075;i=device/device");
          }
          SensorNodeC4: &lt;hostType&gt; like INetworkNode {
              @display("p=2100,1750;i=device/device");
          }
          SensorNodeC5: &lt;hostType&gt; like INetworkNode {
              @display("p=1900,1400;i=device/device");
          }
          SensorNodeD1: &lt;hostType&gt; like INetworkNode {
              @display("p=800,2075;i=device/device");
          }
          SensorNodeD2: &lt;hostType&gt; like INetworkNode {
              @display("p=1000,1700;i=device/device");
          }
          SensorNodeD3: &lt;hostType&gt; like INetworkNode {
              @display("p=650,1450;i=device/device");
          }
          SensorNodeD4: &lt;hostType&gt; like INetworkNode {
              @display("p=350,2050;i=device/device");
          }
          SensorNodeD5: &lt;hostType&gt; like INetworkNode {
              @display("p=275,1625;i=device/device");
          }
  }
  </code></pre>
  
  <p><strong>INI FILE</strong></p>
  
  <pre><code>[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
  </code></pre>
  
  <p>Here the network is getting created but when i try to send a packet from SensorNodeA1 to SubStationA, during simulation the packet is sent from SensorNodeA1 to all the nodes. What should i do to send a packet from one node to another single node? Also i want to record and then draw graph of the packets sent over time and the energy consumption of each nodes. I am still new to OMNet++ so if someone can guide me it will be helpful</p>