Hello!
Is possible to recognise if a received UDP packet is a broadcast packet?
thanks!
Hello!
Is possible to recognise if a received UDP packet is a broadcast packet?
thanks!
It would be a broadcast packet only if your ethernet shield is listening for a broadcast packet.
I'm actually listening for packets with Udp.parsePacket() function with the shield, then how can I know if is a broadcast packet or not?
If your shield IP is not set to the broadcast IP for the localnet, it isn't a broadcast packet.
edit: If the network is 192.168.0.0/24 (netmask 255.255.255.0), then the broadcast IP is 192.168.0.255. If the shield has no IP, then the broadcast IP is 255.255.255.255.
Ethernet.begin(). DHCP uses this. Why do you want to monitor the broadcast IP? Which broadcast IP? Localnet or universal?
Basically for universal, it would be
IPAddress ip(255,255,255,255);
IPAddress subnet(0,0,0,0);
IPAddress gateway(0,0,0,0);
Ethernet.begin(mac,ip,gateway,gateway,subnet);
I could be wrong about the gateway, but it doesn't really matter. There is no IP not on this localnet.
Maybe I'm missing something.
Yes, I'm in a Localnet.
Suppose I have N shields linked in a localnet. Every shield is listening to the same port.
One of this sends a broadcast packet into the net. Every device on the net should read this packet with broadcast address in the destination address field.
Sometimes I need this broadcast, but sometimes not.
Or better some devices needs this broadcast and others not.
So my intent is to know if the arrived packet is a broadcast for all the devices in the net, or is only for me
Thanks very much!
You are not missing anything. The broadcast IP is the last IP in the localnet, whatever that localnet is. Unfortunately, the ethernet shield can only listen to one IP at a time, either the broadcast IP or its assigned IP.
Ethernet.begin(mac,ip,gateway,subnet)
Is the ip inserted in the function the one I will listening to? You're confusing me
I was sure that it was the shield IP I set!
budwhite:
Ethernet.begin(mac,ip,gateway,subnet)
Is the ip inserted in the function the one I will listening to? You're confusing me
I was sure that it was the shield IP I set!
If your Ethernet.begin function call is correct, yes. You are not including the DNS server in your call, so the gateway will be set to the value in your subnet variable. It should be this:
Ethernet.begin(mac,ip,gateway,gateway,subnet)
Ok!
So if do something like this:
Ethernet.begin(mac,ip)
I'm actually not set for listening to broadcast, isn't it?
SurferTim:
If your Ethernet.begin function call is correct, yes. You are not including the DNS server in your call, so the gateway will be set to the value in your subnet variable. It should be this:Ethernet.begin(mac,ip,gateway,gateway,subnet)
(I'm not interested to the DNS, only working on my localnet, is that mandatory?)
I'm actually not set for listening to broadcast, isn't it?
Not unless the ip variable is set to the broadcast IP. If the ip variable is set to xx.xx.xx.255, then you are listening to the localnet broadcast IP. The default subnet mask is 255.255.255.0 if you do not specify it in Ethernet.begin().
// this is not the broadcast IP
IPAddress ip(192,168,0,2);
// this is the broadcast IP
IPAddress ip(192,168,0,255);
thanks