omnet++inettcpreplay

How does send() work in omnet++


Does the send() in omnet++ set the source address of the packet to the current host address?

Why am I asking? because I'm trying to code a class for a malicious host "Eve" that performs a replay attack.

void MalAODVRouter::handleMessage(cMessage *msg)
{

    cMessage *ReplayMsg = msg->dup();
    AODVRouting::handleMessage(msg);

    capturedMsgs++;
    if (capturedMsgs==10) // One out of every 10 packets (frequency of replay)
    {
            //we can add a delay before sending the copy of the message again (1 time unit)
            sendDelayed(ReplayMsg, 1,"ipOut");
            ReplayedMsgs++;
            std::cout<<"Launched Replay Packet!\n";
            ev<<"Launched Replay Packet!\n";

            this->capturedMsgs=0;
       // }
    }

}

You can see at the beginning of my code snippet I tried using the function dup() to duplicate a packet (msg) Eve's receives while its on it's on its way to the legitimate destination. Now, can I send the duplicated packet later and it would be having the original source address OR should I dig deeper into layers to fake the source address to have Bob's address instead of Eve's? like below:

/*UDPPacket *udpPacket = dynamic_cast<UDPPacket *>(msg);
            AODVControlPacket *ctrlPacket = check_and_cast<AODVControlPacket *>(udpPacket->decapsulate());
            IPv4ControlInfo *udpProtocolCtrlInfo = dynamic_cast<IPv4ControlInfo *>(udpPacket->getControlInfo());
            ASSERT(udpProtocolCtrlInfo != NULL);
            IPv4Address sourceAddr = udpProtocolCtrlInfo->getSrcAddr();         //get Source Address
            IPv4Address destinationAddr = udpProtocolCtrlInfo->getDestAddr();   //get Destination Address
            IPv4Address addr = getSelfIPAddress();
            if (addr != destinationAddr)      // if it is not destined for "Eve"
            {
                UDPPacket *ReplayUDPPacket = udpPacket;
                AODVControlPacket *ReplayCtrlPacket = check_and_cast<AODVControlPacket *>(ReplayUDPPacket->decapsulate());
                IPv4ControlInfo *ReplayUDPProtocolCtrlInfo = dynamic_cast<IPv4ControlInfo *>(ReplayUDPPacket->getControlInfo());
                ASSERT(ReplayUDPProtocolCtrlInfo != NULL);
                ReplayUDPProtocolCtrlInfo->setSrcAddr(sourceAddr);          //Forge Source
                ReplayUDPProtocolCtrlInfo->setDestAddr(destinationAddr);    //Keep Destination

    */

                //we can add a delay before sending the copy of the message again (1 time unit)
                sendDelayed(ReplayMsg, 1,"ipOut");
                ReplayedMsgs++;
                std::cout<<"Launched Replay Packet!\n";
                ev<<"Launched Replay Packet!\n";

                this->capturedMsgs=0;

Does the send() method automatically sets the source address of the outgoing packet to the current host address? If so, then my replay attempt is not working...


Solution

  • send() is an OMNeT++ API call. As OMNeT++ is just a generic discrete event simulation framework, it does not know anything about the model code (so it cannot and should not manipulate it). IP address is a defined in the INET framework so only code from the INET framework can change it.

    On the other hand the modules in the standard host below you module can do whatever they want before the packet is sent out to the network. Now in this actual case, the source IP address is determined by the control info that is attached to the packet. dup()-ing the packet copies that information too, so the IP address will be the same.