I was thinking about broadcasting in an ad-hoc local area network, then i asked me a question.Assuming that this LAN is made of 2 pc, if this pc have the same IP address, Can i send udp packet from one to the other, with broadcast address ? I know that a packet send to broadcast address is "catched" by all pc in the network, but , is broadcasting equal to send packet on all address one by one ( mean that a packet send to the IP address "myipaddress" don't go out of my pc) or is it Different ( mean that the packet go out of my pc and all pc on the network consider that it is for theim, no matter if their IP address is different or equal to myipaddress ). Thank.
There are a couple of issues here.
1) I'm not sure of all IP network stacks, but often the driver will drop packets it perceived to be sent by itself. This can often be got round with listening for raw packets, but this will require a privileged state
2) What address does this get sent back to. Generally applications (and possibly the IP stack), expects to send back to the sending address. If this is it's own address I'm not sure how the stack will cope. Again you could mess with this.
In the end you might be better off just sending raw data out in ethernet packets and listening that way. One major element of this puzzle of this to understand how to solve this, is why are you wanting to do this. Why are you expecting the computers to have the same IP, will this be always true or is it just to cover if two PCs end up picking the same IP address?