EmbeddedRelated.com
Forums

Multicast

Started by "see...@yahoo.com [rabbit-semi]" July 21, 2016
Steve,

Good to know. I recently ran into trouble with Wireshark as well, and was really confused about what I was seeing. I was trying to monitor packets going in/out of an Ubuntu VM. One day, everything was working properly. A few days later, it was only capturing one side of the UDP connections.

If I need to capture again, I'll be sure to restart Wireshark after starting everything. I thought I had tried doing that, but maybe I was just trying it after launching the VM.

-Tom
On Jul 27, 2016, at 12:48 PM, Steve Trigero s...@yahoo.com [rabbit-semi] wrote:

> Well, it turns out to be a wireshark issue. This latest version of wireshark is not as user friendly as it used to be.
>
> So check this out. I have an RM3900 setup to send a UDP datagram every 500ms to either a Multicast IP or to a
> Broadcast IP. I send a command to the Rabbit telling it which protocol to use.
>
> I set the Rabbit to use broadcast then start wireshark. It captures all the broadcast traffic. I tell the Rabbit to switch
> to using Multicast and wireshark goes silent. I close wireshark and reopen it. Presto! The multicast datagrams show
> up in the capture. Switch back to sending broadcasts. Wireshark goes silent again. Close and reopen, and theystart
> showing up again.
>
> So the Rabbit appears to be working, wireshark not so much.
>
> Steve
Steve,

Back from vacation and wanting to follow up on your message. I'm looking through Dynamic C's TCP/IP stack and have the following to report:

* MAX_UDP_SOCKET_BUFFERS should be equal to the number of UDP sockets you're opening. There's no benefit to setting it higher than the number of sockets -- it's used to store copies of the udp_Socket pointer passed into udp_open().

* The stack allocates UDP_BUF_SIZE of space for each of the MAX_UDP_SOCKET_BUFFERS.

* As best as I can tell, the UDP sockets each get UDP_BUF_SIZE bytes. This is good in that a single UDP socket can't starve out other sockets, but it requires you to keep up with datagrams.

* So, I would advise on setting MAX_UDP_SOCKET_BUFFERS based on how many simultaneous UDP sockets you'll have open, and UDP_BUF_SIZE based on how much data you expect to receive between calls to udp_recv().

* If you have just one UDP socket that requires a larger buffer, consider using udp_extopen() to give it a large buffer so you don't waste space by over allocating buffers (via UDP_BUF_SIZE) for your other UDP sockets.

Let me know if you still have any outstanding questions on how the UDP sockets work in Dynamic C, or if the issues you saw were caused by the Wireshark capture bugs you mentioned in another message.

-Tom
On Jul 22, 2016, at 9:19 AM, Steve Trigero s...@yahoo.com [rabbit-semi] wrote:

> Yes, I was referring to MAX_UDP_SOCKET_BUFFERS. I know I need them. I was asking about
> the ratio of sockets to buffers. Could I get away with a single UDP socket and say 5 buffers without
> dropping datagrams?
>
Thanks for the information.  I did just what you suggested and it seems to work.
Regarding wireshark I have some new  information.  The problem with capturing multicast packets may not have been a wireshark issue. I ran into someone else that had the same  problem, and he determined that the multicast port number had to be opened on the PC before wireshark could capture. 
He used the following Python 3 script to open the port:
#!/usr/bin/env python
import socket
import structMCAST_GRP = '224.0.100.100'
MCAST_PORT = 52200sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', MCAST_PORT))  # use MCAST_GRP instead of '' to listen only
                                                    # to MCAST_GRP, not all groups on MCAST_PORT
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)while True:
  print(sock.recv(10240))
From: "Tom Collins t...@tomlogic.com [rabbit-semi]"
To: r...
Sent: Tuesday, August 2, 2016 4:47 PM
Subject: Re: [rabbit-semi] Multicast

  Steve,
Back from vacation and wanting to follow up on your message.  I'm looking through Dynamic C's TCP/IP stack and have the following to report:
* MAX_UDP_SOCKET_BUFFERS should be equal to the number of UDP sockets you're opening.  There's no benefit to setting it higher than the number of sockets -- it's used to store copies of the udp_Socket pointer passed into udp_open().
* The stack allocates UDP_BUF_SIZE of space for each of the MAX_UDP_SOCKET_BUFFERS.
* As best as I can tell, the UDP sockets each get UDP_BUF_SIZE bytes.  This is good in that a single UDP socket can't starve out other sockets, but it requires you to keep up with datagrams.
* So, I would advise on setting MAX_UDP_SOCKET_BUFFERS based on how many simultaneous UDP sockets you'll have open, and UDP_BUF_SIZE based on how much data you expect to receive between calls to udp_recv().
* If you have just one UDP socket that requires a larger buffer, consider using udp_extopen() to give it a large buffer so you don't waste space by over allocating buffers (via UDP_BUF_SIZE) for your other UDP sockets.
Let me know if you still have any outstanding questions on how the UDP sockets work in Dynamic C, or if the issues you saw were caused by the Wireshark capture bugs you mentioned in another message.
-Tom

On Jul 22, 2016, at 9:19 AM, Steve Trigero s...@yahoo.com [rabbit-semi] wrote:

Yes, I was referring to MAX_UDP_SOCKET_BUFFERS. I know I need them. I was asking aboutthe ratio of sockets to buffers.  Could I get away with a single UDP socket and say 5 buffers withoutdropping datagrams? 
#yiv8089521912 #yiv8089521912 -- #yiv8089521912ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8089521912 #yiv8089521912ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8089521912 #yiv8089521912ygrp-mkp #yiv8089521912hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8089521912 #yiv8089521912ygrp-mkp #yiv8089521912ads {margin-bottom:10px;}#yiv8089521912 #yiv8089521912ygrp-mkp .yiv8089521912ad {padding:0 0;}#yiv8089521912 #yiv8089521912ygrp-mkp .yiv8089521912ad p {margin:0;}#yiv8089521912 #yiv8089521912ygrp-mkp .yiv8089521912ad a {color:#0000ff;text-decoration:none;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ygrp-lc {font-family:Arial;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ygrp-lc #yiv8089521912hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ygrp-lc .yiv8089521912ad {margin-bottom:10px;padding:0 0;}#yiv8089521912 #yiv8089521912actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8089521912 #yiv8089521912activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8089521912 #yiv8089521912activity span {font-weight:700;}#yiv8089521912 #yiv8089521912activity span:first-child {text-transform:uppercase;}#yiv8089521912 #yiv8089521912activity span a {color:#5085b6;text-decoration:none;}#yiv8089521912 #yiv8089521912activity span span {color:#ff7900;}#yiv8089521912 #yiv8089521912activity span .yiv8089521912underline {text-decoration:underline;}#yiv8089521912 .yiv8089521912attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8089521912 .yiv8089521912attach div a {text-decoration:none;}#yiv8089521912 .yiv8089521912attach img {border:none;padding-right:5px;}#yiv8089521912 .yiv8089521912attach label {display:block;margin-bottom:5px;}#yiv8089521912 .yiv8089521912attach label a {text-decoration:none;}#yiv8089521912 blockquote {margin:0 0 0 4px;}#yiv8089521912 .yiv8089521912bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8089521912 .yiv8089521912bold a {text-decoration:none;}#yiv8089521912 dd.yiv8089521912last p a {font-family:Verdana;font-weight:700;}#yiv8089521912 dd.yiv8089521912last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8089521912 dd.yiv8089521912last p span.yiv8089521912yshortcuts {margin-right:0;}#yiv8089521912 div.yiv8089521912attach-table div div a {text-decoration:none;}#yiv8089521912 div.yiv8089521912attach-table {width:400px;}#yiv8089521912 div.yiv8089521912file-title a, #yiv8089521912 div.yiv8089521912file-title a:active, #yiv8089521912 div.yiv8089521912file-title a:hover, #yiv8089521912 div.yiv8089521912file-title a:visited {text-decoration:none;}#yiv8089521912 div.yiv8089521912photo-title a, #yiv8089521912 div.yiv8089521912photo-title a:active, #yiv8089521912 div.yiv8089521912photo-title a:hover, #yiv8089521912 div.yiv8089521912photo-title a:visited {text-decoration:none;}#yiv8089521912 div#yiv8089521912ygrp-mlmsg #yiv8089521912ygrp-msg p a span.yiv8089521912yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv8089521912 .yiv8089521912green {color:#628c2a;}#yiv8089521912 .yiv8089521912MsoNormal {margin:0 0 0 0;}#yiv8089521912 o {font-size:0;}#yiv8089521912 #yiv8089521912photos div {float:left;width:72px;}#yiv8089521912 #yiv8089521912photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv8089521912 #yiv8089521912photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8089521912 #yiv8089521912reco-category {font-size:77%;}#yiv8089521912 #yiv8089521912reco-desc {font-size:77%;}#yiv8089521912 .yiv8089521912replbq {margin:4px;}#yiv8089521912 #yiv8089521912ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8089521912 #yiv8089521912ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv8089521912 #yiv8089521912ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8089521912 #yiv8089521912ygrp-mlmsg select, #yiv8089521912 input, #yiv8089521912 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8089521912 #yiv8089521912ygrp-mlmsg pre, #yiv8089521912 code {font:115% monospace;}#yiv8089521912 #yiv8089521912ygrp-mlmsg * {line-height:1.22em;}#yiv8089521912 #yiv8089521912ygrp-mlmsg #yiv8089521912logo {padding-bottom:10px;}#yiv8089521912 #yiv8089521912ygrp-msg p a {font-family:Verdana;}#yiv8089521912 #yiv8089521912ygrp-msg p#yiv8089521912attach-count span {color:#1E66AE;font-weight:700;}#yiv8089521912 #yiv8089521912ygrp-reco #yiv8089521912reco-head {color:#ff7900;font-weight:700;}#yiv8089521912 #yiv8089521912ygrp-reco {margin-bottom:20px;padding:0px;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ov li a {font-size:130%;text-decoration:none;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv8089521912 #yiv8089521912ygrp-sponsor #yiv8089521912ov ul {margin:0;padding:0 0 0 8px;}#yiv8089521912 #yiv8089521912ygrp-text {font-family:Georgia;}#yiv8089521912 #yiv8089521912ygrp-text p {margin:0 0 1em 0;}#yiv8089521912 #yiv8089521912ygrp-text tt {font-size:120%;}#yiv8089521912 #yiv8089521912ygrp-vital ul li:last-child {border-right:none !important;}#yiv8089521912