Hi,
I 'm trying to generate an echo like in UDPEchoApp. In the initialize I did the following code:
localPort = par("localPort");
destPort = par("destPort");
socket.setOutputGate(gate("udpOut"));
socket.bind(localPort);
setSocketOptions();
When I send a packet to a particular destination, everything works well and the packet is processed. But when packet is processed I am trying to send an acknowledgement packet to the sender by doing the below code:
UDPDataIndication *ctrl;
ctrl = check_and_cast<UDPDataIndication *> (msg->getControlInfo());
socket.sendTo(createACKpkt(msg), (IPvXAddressResolver().resolve(rcheck, IPvXAddressResolver().ADDR_IPv4)), destPort);
Where destPort is 1234 and the IP address to send to is the correct IP address of the node that sent the packet. But when the packet reaches the node with this IP address I get the below error in the output:
No socket registered on port 24899
sending ICMP error ICMP-error-#3-type13-code3
And so the packet is deleted. I know that the error means that the destination is unreachable but I don't understand why the destination port is changing from 1234 to 24899?
Also I suspect the error might come from when receiving a packet and calling UDPSocket::getReceivedPacketInfo(msg), the below output is seen
Received IVC Message: (PACKET)Created IVC Data Packet to Car[6] (12 bytes)
192.168.0.2:1234 -->
192.168.0.2:1234 TTL=31 ToS=0 on ifID=101
When in fact, the destination IP address was suppose to be of another node with IP 192.168.0.1 not 192.168.0.2
Why are these error happening, please? and how can I fix them?
Thanks in advance