Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthernetUDP in Multicast - packet are sent to EthernetUDP source port instead of the destination port #271

Open
NeyVian opened this issue Jul 11, 2024 · 4 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@NeyVian
Copy link

NeyVian commented Jul 11, 2024

How to reproduce the issue :

EthernetUDP mcast_udp;
IPAddress mcast_group(230, 1, 1, 1);
uint16_t recv_port = 49500;
uint16_t dest_port = 49600;
mcast_udp.beginMulticast(mcast_group, recv_port);
mcast_udp.beginPacket(mcast_group, dest_port);
mcast_udp.write("some data");
mcast_udp.endPacket();

with this code the packet is sent from recv_port to recv_port, and not to dest_port.

This can be fixed in
socket.cpp > bool EthernetClass::socketSendUDP(uint8_t s)
by replacing
W5100.execCmdSn(s, Sock_SEND);
with
W5100.execCmdSn(s, ((W5100.readSnMR(s) & SnMR::MULTI) == SnMR::MULTI) ? Sock_SEND_MAC : Sock_SEND);

@JAndrassy
Copy link
Contributor

JAndrassy commented Jul 12, 2024

it is designed to use the same port for receiving and sending

@NeyVian
Copy link
Author

NeyVian commented Jul 12, 2024

it is designed to use the same port for receiving and sending

can you provide a source please ?

@JAndrassy
Copy link
Contributor

that is not a right use of SEND_MAC. from W5500 datasheet

SEND_MAC transmits data without the automatic ARP-process. In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Jul 12, 2024
@NeyVian
Copy link
Author

NeyVian commented Jul 12, 2024

that is not a right use of SEND_MAC. from W5500 datasheet

SEND_MAC transmits data without the automatic ARP-process. In this case, the destination hardware address is acquired from Sn_DHAR configured by host, instead of APR-process.

Multicast don't rely on ARP-process. no need to match an IP to a MAC as the group defines the destination MAC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants