Search code examples
unetstack

Logging packet sent time by physical layer


From the sender node i am sending packet by command in simulation script: router << new DatagramReq(to: 1, data:[1,1,1,1], protocol:Protocol.DATA); I want to know, how to log the Datagram sent time by Physical layer of the sender in log-0.txt file


Solution

  • Setting the log level of the agent to FINE should log all messages sent by that agent. The logger name for each agent follows the class name of the agent, by convention. If you do a ps, you'll see the class names of the agents:

    > ps
    remote: org.arl.unet.remote.RemoteControl - IDLE
    rdp: org.arl.unet.net.RouteDiscoveryProtocol - IDLE
    ranging: org.arl.unet.phy.Ranging - IDLE
    uwlink: org.arl.unet.link.ReliableLink - IDLE
    node: org.arl.unet.nodeinfo.NodeInfo - IDLE
    phy: org.arl.unet.sim.HalfDuplexModem - IDLE
    arp: org.arl.unet.addr.AddressResolution - IDLE
    transport: org.arl.unet.transport.SWTransport - IDLE
    router: org.arl.unet.net.Router - IDLE
    mac: org.arl.unet.mac.CSMA - IDLE
    

    You can see that the phy agent class is org.arl.unet.sim.HalfDuplexModem, if you're running a simulator. You can set the log level of the simulation classes to INFO:

    > logLevel 'org.arl.unet.sim', FINE
    

    Now, the logs will show the messages (and their corresponding times). Example:

    1567801752688|FINE|org.arl.unet.sim.HalfDuplexModem/A@47:handleTxFrameReq|TxFrameReq:REQUEST[type:DATA to:1 (4 bytes)] Data:
        01010101
    1567801752741|FINE|org.arl.unet.sim.HalfDuplexModem/A@47:sendTxFrameNtf|TxFrameNtf:INFORM[type:DATA txTime:753410296]
    1567801753392|FINE|org.arl.unet.sim.HalfDuplexModem/B@63:sendRxFrameStartNtf|RxFrameStartNtf:INFORM[type:DATA rxTime:3515132027]
    1567801754095|FINE|org.arl.unet.sim.HalfDuplexModem/B@63:sendRxFrameNtf|RxFrameNtf:INFORM[type:DATA from:232 to:1 rxTime:3515132027 (4 bytes)] Data:
        01010101