Answer the question
In order to leave comments, you need to log in
How to fake sender address in UDP packet?
You need to test a program that accepts UDP packets from certain addresses. If the address is correct, we parse the message.
I am writing a test program in which several Udp sockets are created and a message is sent.
The QAbstractSocket class has a setLocalAddress(const QHostAddress & address) [protected] method, which seems to be supposed to replace the sender address. But in Wireshark-e I see that the address is not substituted.
Is it possible to make such a substitution in principle?
How to do it in C++/Qt?
Answer the question
In order to leave comments, you need to log in
setLocalAddress can only be set to addresses present on local interfaces. An arbitrary address cannot be set. That. you can either add the desired address to the local interface (for example, using ifconfig add), or open a "raw" socket and form IP and UDP headers yourself.
Most likely not, because using such libs you are too high from the drivers.
Look at the pcap library (but it does not work with all network cards) and do what you need.
No one forbids sending a packet in which the header contains a non-native address (except for the equipment through which you spit packets into the public network).
Can generate a package like this: linkmeup.ru/blog/121.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question