MCF52235, Interniche Lite 7, UDP Broadcast

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52235, Interniche Lite 7, UDP Broadcast

1,378 Views
jab
Contributor III

Hi all,

 

I'm attempting to do a UDP broadcast using my MCF52235EVB. My PC is setup with IP address 100.1.3.186, subnet 255.255.0.0. In the "main.c" file i set my board's IP to 100.1.3.100 and subnet to 255.255.0.0.

 

I then played around with the "freescale_UDP_client.c" file to send UDP packets to my PC. it works fine if i set my send address to that of my PC. but what i want to do is send packets to any PC with IP 100.1.3.x. To do this i set my send address to 100.1.3.255, but now my PC cannot see the packets.

 

I ran Wireshark (network monitoring software) and found that my PC can see the packets but keeps asking "who is 100.1.3.255?". So basically my PC thinks that 100.1.3.255 is a specific PC's address and not a broadcast.

 

What changes to the Interniche code do i have to make to be able to broadcast UDP packets to any PC with address 100.1.3.x?

 

I have attached both files. Any help or input would be greatly appreciated, thank you.

Labels (1)
0 Kudos
5 Replies

542 Views
TomE
Specialist II

> I'm attempting to do a UDP broadcast using my MCF52235EVB. My PC is setup

> with IP address 100.1.3.186, subnet 255.255.0.0. In the "main.c" file i set my

> board's IP to 100.1.3.100 and subnet to 255.255.0.0.

> my PC thinks that 100.1.3.255 is a specific PC's address and not a broadcast.

 

That's because it is a host address. The subnet mask defines which part of the IP address is the "net" and which is the "host".

 

So your network is "100.1.0.0" and the host part ranges from 0.1 to 255.254.

 

And the BROADCAST address is 100.1.255.255.

 

100.1.3.255 is only the broadcast address when the subnet mask is 255.255.255.0.

 

0 Kudos

542 Views
jab
Contributor III

i've changed my settings to the following:

 

BOARD:

IP: 100.1.3.100

Subnet: 255.255.0.0

Sending to: 100.1.255.255, Port: 30100

 

PC:

IP: 100.1.3.186

Subnet: 255.255.0.0

Listening on Port 30100

 

My PC still can't receive the packets. I just get an ARP asking "Who is 100.1.255.255??" on WireShark.

 

Any help?

0 Kudos

542 Views
TomE
Specialist II

Try sending broadcast packets from that PC to itself. Try sending broadcast packets from a different PC to that one.

 

You didn't say that Wireshark can see the packets from the board. I assume it can or you wouldn't be seeing the ARPs.

 

What SOURCE and DESTINATION ETHERNET addresses is Wireshark seeing in the packet from the board? The packet should contain the Ethernet Source address of the board and the Ethernet Destination address of "all ones" (the broadcast address).

 

What SOURCE and DESTINATION IP addresses is Wireshark seeing in the packet from the board? The packet should contain the IP Source address of the board and the broadcast IP Destination address of "10.1.255.255".

 

Since the PC is then ARPing for "10.1.255.255" then either the PC program is buggy and is trying to reply to the DESTINATION address instead of the SOURCE address, or the Board is setting the SOURCE IP address in the packet to "10.1.255.255".

 

When it works (without broadcasts), the Board sends a packet to the PC, and the PC then replies to the SOURCE IP address of the packet.

 

When using broadcasts, the same thing has to happen. The PC has to reply to the SOURCE IP address. It isn't doing that (it looks to be trying to reply to "10.1.255.255)", so that should point to the mistake.

 

 

0 Kudos

542 Views
jab
Contributor III

I've tried sending broadcast packets (ie destination 100.1.255.255) to my PC and my PC receives it fine. I've attached a printsceen of what Wireshark sees, see file.

 

Wireshark sees an ARP being broadcasted saying "Who has 100.1.255.255? Tell 100.1.3.100".

 

100.1.3.100 is my board's address...it's the one sending the packet. my PC is just supposed to receive it.

0 Kudos

542 Views
TomE
Specialist II

> Wireshark sees an ARP being broadcasted saying "Who has 100.1.255.255? Tell 100.1.3.100".

> 100.1.3.100 is my board's address...it's the one sending the packet. my PC is just supposed to receive it.

 

The ARP is being sent by 00:cf:52:53:54:55 ("RSTU" in last 4 bytes). That is a more trustworthy identification of the source than the IP address.

 

So the board is sending those ARPs. That is because the board doesn't "know" that 100.1.255.255 is a broadcast address.

 

So either the IP address configuration is wrong, the IP stack is buggy or you're not driving it properly.

 

I have no idea how Interniche Lite 7 works (and don't want to, so don't ask me Smiley Happy, but here are all the different ways it might be implemented. You'll have to pattern-match it against these and work out what is wrong.

 

In general, when the IP stack goes to send a packet it has to check the destination IP address to see (a) which interface to send it out (if there's more than one, unlikely in this case), (b) whether the destination address is on the local network, or whether it is "somewhere else" and has to be sent to a router instead, and then for "local and router" it has to find the Ethernet address of the local device or the local router. Then it has to work out if the address is a broadcast. This is the bit that is going wrong. As an added complexity, it might be a Multicast destination (also not likely to be supported).

 

1 - One way is to check the address against the subnet mask. If the node part is all-ones it is a broadcast. For backwards-compatibility it might also check against all-zeros which is a very old broadcast address.

 

2 - Another way is to have a "broadcast address" separately configured for the port. The code then compares against that fixed IP address.

 

3 - Another way is to "seed" the ARP Cache with a static entry mapping "100.1.255.255" to "ff:ff:ff:ff:ff:ff". That way the code that handles mapping an IP address to an Ethernet address doesn't have to do anything special - it finds the broadcast one the same way it finds a normal one.

 

4 - Another way is to require the Application code to send a flag through to the stack stating "I want this to be broadcast".

 

So check the subnet mask (again), check if there's an "all ones, all zeros or both" Broadcast option, check if there's a configured Broadcast address and if there's a need for the App to specify broadcasts. Then add some code to dump the ARP cache in case it is meant to be seeded, and if so, seeded with what.

 

Or (like I should have done), search this forum first. This looks interesting:

 

http://forums.freescale.com/t5/68K-ColdFire-reg-Microprocessors/Subnetting-with-NicheLite/m-p/52731#...

 

 

Re: Subnetting with NicheLite
2010-03-01 12:22 PM
...
There are serious problems with the way broadcasts are handled, resulting in only the all-bits set broadcast working as a side effect of buggy code that fails to handle the subnet broadcast.
...
but routing with a router is still dead, with or without DHCP turned on.
The comment at the top of the file, "no real routing", says a lot, I
had more expectations for NicheLite than it's going to deliver.  I'm
going to drop back, document the limitation to the end users, and maybe
lock out the ability for them to set a subnetmask and gateway.

 

That doesn't look at all good. It implies that this code has thirty-year-old bugs in it if it can't handle broadcasts and if it still has "subnet confusion" (CIDR got rid of that in 1993!). The code isn't 30 years old, just that new programmers keep making 30-year-old mistakes Smiley Happy.

 

The "doesn't do routing" comment could mean that it only works as a host (and can't route between multiple interfaces, which is find) or it might be more serious and mean that it can't send to gateways properly.

 

It only needs one line of code in there that says "if destination address and mask matches broadcast then ethernet address is broadcast, else do the ARP thing" to handle broadcasts in this case. You could probably add that yourself.

 

It looks like it might only support simple host-to-host messages, and then only on the one network too. It might rely on DHCP (or not work with DHCP).

 

0 Kudos