W5500 Broadcast Server
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5500 Broadcast Server
by Eugeny ·
To receive broadcast packets in UDP mode you must ensure to reset BCASTB of Sn_MR. However it is a good question if W5500 supports 192.168.178.255 to be broadcast address for network 255.255.255.0 - I did not try it. But should work this way.
What do you want W5500 to respond with? And UDP broadcast does also have the UDP port #.
RE: RE: W5500 Broadcast Server
by vanvught ·
I can confirm that it is working. I calculate the broadcast address as following:
m_Node.IPAddressBroadcast = m_Node.IPAddressLocal | ~(Network::Get()->GetNetmask());where the m_Node.IPAddressLocal is 192.168.2.x and the netmask is 255.255.255.0
Both sending and receiving UDP broadcast is working fine.
RE: W5500 Broadcast Server
by zhang ·
Thanks for the quick answer!
But difficult to figure out why getSn_RX_RSR(UDP_SOCK_NR) always returns zero.
I believe that it must be a trivial error
Below is the C Code for testing: any idea ?
#define UDP_SOCK_NR 0
#define TCP_SOCK_NR 1
#define DHCP_SOCK_NR 2
#define TCP_PORT 51000
#define UDP_PORT 51000
#define UDP_FLAG Sn_MR_BCASTB
wiz_NetInfo gWIZNETINFO = { .mac = {0x00, 0x08, 0xdc, 0xab, 0xcd, 0xef}, // just for testing
.ip = {192, 168, 178, 2},
.sn = {255, 255, 255, 0},
.gw = {192, 168, 178, 1},
.dns = {0, 0, 0, 0},
.dhcp = NETINFO_DHCP };
void eth_init(void)
{
…
}
void udp_task(void)
{
…
switch(getSn_SR(UDP_SOCK_NR))
{
case SOCK_UDP :
if((size = getSn_RX_RSR(UDP_SOCK_NR)) > 0) // goes here: and size=0 ?
{
if(size > TX_RX_MAX_BUF_SIZE) size = TX_RX_MAX_BUF_SIZE;
if( recvfrom(UDP_SOCK_NR, buf, size, destip, (uint16_t*)&destport) <= 0) break;
}
RE: RE: W5500 Broadcast Server
by Eugeny ·
I was wrong, this bit
Sn_MR_BCASTBmust be reset! (I corrected my previous post). So effective UDP_FLAG should be 0.From datasheet:
RE: W5500 Broadcast Server
by Eugeny ·
So what is the problem then?
If
Then I guess you must write code which will respond to these broadcast datagrams.
RE: W5500 Broadcast Server
by zhang ·
The Problem is getSn_RX_RSR(UDP_SOCK_NR) is always Zero.
Also tested with free UDP Tools.
RE: W5500 Broadcast Server
by Eugeny ·
Before several posts above you said
and now you say that RSR is always 0. So it is NOT working? And please explain what is not working, how it does not work, how you think it must work, and attach wireshark logs of what is going on the W5500 interface to prove that there’re actual packets to be received by the W5500 (not wireshark log from another endpoint, but wireshark log from the last device in the chain just before W5500 - you may need to draw the diagram of your network).
RE: W5500 Broadcast Server
by vanvught ·
Hi Eugeny, please note that there are 2 different users replying here. I was confirming your remark. Zhang has the issue.
RE: W5500 Broadcast Server
by Eugeny ·
Thank you very much for pointing me, should have seen it before!
Thus if you have it working properly, it means that things should work, and Zhang should have some mistake - in chip configuration or in the wire.
RE: W5500 Broadcast Server
by zhang ·
udp.zip (198,2 KB)
this is the Wireshark log file.
PC: 192.168.178.21
W5500: 192.168.178.2
Also verified that data can be sent from W5500 to PC with sendto(UDP_SOCK_NR, Buf, 4, destip, destport); (UDP Tools received the message.)
But getSn_RX_RSR(UDP_SOCK_NR) is 0 when PC send message to W5500 (even dest-IP 192.168.178.2 or 192.168.178.255) .
As already mentioned, TCP works.
RE: RE: W5500 Broadcast Server
by Eugeny ·
Ok, seems packet is ok (however length of 12 looks strange, maybe wireshark does not show padding). Looking into your code:
Why do you make socket for TCP first, then set up destination address of 0, and then, without closing the socket, trying to reinint it in UDP mode?
Why not open socket in UDP mode from the beginning (issuing CLOSE command beforehand to ensure that socket is closed properly)? There’s specific sequence to make things properly, look at W5100 datasheet chapter 5.
RE: W5500 Broadcast Server
by zhang ·
Just changed the order like this:
socket(UDP_SOCK_NR, Sn_MR_UDP, UDP_PORT, 0x00);
socket(TCP_SOCK_NR, Sn_MR_TCP, TCP_PORT, 0x00);
while(getSn_SR(TCP_SOCK_NR) != SOCK_INIT);
It works now (do not know why). Great!
Thank you very much.
RE: RE: W5500 Broadcast Server
by Eugeny ·
Why do you open socket in one mode, and then open in another? If you use UDP, you do not needsocket(TCP_SOCK_NR, Sn_MR_TCP, TCP_PORT, 0x00);!I see these are two different sockets
It is actually strange because operation of different sockets must be independent, and given you open one for UDP and another in TCP there should be no conflicts.