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

examples:rpl_udp removed the limit of 5 characters as payload size #2742

Merged
merged 1 commit into from
Mar 31, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions examples/rpl_udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,21 @@ int udp_send(int argc, char **argv)
ipv6_addr_t ipaddr;
int bytes_sent;
int address;
char text[5];

if (argc != 3) {
printf("usage: send <addr> <text>\n");
return 1;
}

address = atoi(argv[1]);
/* max payload size = MTU - MAC - AES - IPV6_HDR_LEN - UDP_HDR_LEN
* 33 = 127 - 25 - 21 - 40 - 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't your calculation based on the 802.15.4 MTU? Using this example e.g. via ethernet and ipv6 would yield room for a far bigger payload size

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, but I thought that the minimal average is most suiting here since the example should be runnable on every supported hardware

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can live with the minimal average (:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimal average would be the cc1100 with 58, but since this is smaller than 0 with above calculation, I guess we are okay :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have fragmentation for that?

*/
if (strlen(argv[2]) > 32) {
puts("<text> is too large to be sent (max. 33 characters).");
return 1;
}

strncpy(text, argv[2], sizeof(text));
text[sizeof(text) - 1] = 0;
address = atoi(argv[1]);

sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);

Expand All @@ -134,8 +138,8 @@ int udp_send(int argc, char **argv)
memcpy(&sa.sin6_addr, &ipaddr, 16);
sa.sin6_port = HTONS(SERVER_PORT);

bytes_sent = socket_base_sendto(sock, (char *)text,
strlen(text) + 1, 0, &sa,
bytes_sent = socket_base_sendto(sock, argv[2],
strlen(argv[2]), 0, &sa,
sizeof(sa));

if (bytes_sent < 0) {
Expand Down