[ros-users] [Discourse.ros.org] [ROS Projects] [Experimental] UDP Broadcast transport layer

Alexis Paques ros.discourse at gmail.com
Mon Jul 17 09:30:55 UTC 2017



Hi all,

I made a proof of concept, meaning still experimental, of the **UDP Broadcast transport layer** and how it could work. 

The final aim is to make a multimaster implementation with UDP Broadcast to avoid WiFi struggle.

I would like some advice of what is wrong and how to improve. 

**Architecture:**

1. Topic negotiation -  Both the Subscriber/Publisher uses a TCP service to get the publishing port from the `organizer.py`
2. Publisher serialize the packets into a Msg message then broadcast the packets to the port given by the organizer.
3. The subscriber binds to the port, deserialize packets and either send it to the callback or publish it on the local master

**Known limitations:**

* Not secure (publisher ip not checked, not crypted)
* 64k maximum packet size (from IP protocol), tested only for non fragmented packets of less than 1k
* ROS Indigo 
* Python 2.7

**Usage:**

```bash
roscore &
rosrun multimaster_udp organizer.py

# in another terminal
rosrun multimaster_udp smallest_subscriber_udp.py
# in another terminal
rosrun multimaster_udp smallest_publisher_udp.py
```

***UDP Subscriber:***
```python
#!/usr/bin/env python
import rospy

from multimaster_udp.transport import UDPSubscriber
from std_msgs.msg import String

def callback(data, topic):
    global counter
    counter += 1
    print data, "\n received",counter, "UDP messages from \n", topic

def main():
    global counter
    counter = 0
    rospy.init_node("smallest_subscriber_udp")
    # if the callback is not defined (None), it will publish locally 
    # to the equivalent topic.
    sub = UDPSubscriber("hello", String, callback=None)
    rospy.spin()

if __name__ == '__main__':
    main()
```

***UDP Broadcast Publisher***
```
#!/usr/bin/env python
import rospy

from multimaster_udp.transport import UDPPublisher
from std_msgs.msg import String

def main():
    rospy.init_node("smallest_broadcast_publisher_udp")

    msg = String("World")
    pub = UDPPublisher("hello", String)

    rate = rospy.Rate(100)
    while not rospy.is_shutdown():
        pub.publish(msg)
        rate.sleep()

if __name__ == '__main__':
    main()
```





---
[Visit Topic](https://discourse.ros.org/t/experimental-udp-broadcast-transport-layer/2226/1) or reply to this email to respond.




More information about the ros-users mailing list