Giter Site home page Giter Site logo

go-multicast's Introduction

Experiments in UDP Multicasting

I have long been fascinated by broadcast networks. In the biological context, broadcast networks (and eavesdropping) are a central feature of anuran and insect choruses.

In TCP/IP there is a similar mechanism provided for in the UDP broadcast and multicast. This package wraps Golang's UDP functions in the net package.

Background

The following is rephrased from here.

Broadcast sends packets to all devices on a LAN. Unlike multicasting, there is no mechanism to limit the recipients of a broadcast: all packets go to all devices whether they want them or not. There is no mechanism to forward broadcasts between LANs.

Multicast sends packets to all devices in a specified group. Membership in a group is set up when devices send "join" packets to an upstream router, and routers and switches keep track of this membership. When multicast packets arrive at a switch, they are only sent to devices or segments (such as WiFi) where at least one device wants them. Multicast can traverse the networks where it has been configured.

Examples

This package comes with some small command line utilities in the examples dir.

In a terminal window, run the following from the root of this repository.

$ go run examples/pinger/main.go
# => Broadcasting to 239.0.0.0:9999

In a separate terminal window, run the following, also from the root of this repository.

$ go run examples/listener/main.go
# => Listening on 239.0.0.0:9999
# 2017/04/12 12:53:24 13 bytes read from 192.168.1.129:51335
# 2017/04/12 12:53:24 00000000  68 65 6c 6c 6f 2c 20 77  6f 72 6c 640a           |hello, world.|
#
# 2017/04/12 12:53:25 13 bytes read from 192.168.1.129:51335
# 2017/04/12 12:53:25 00000000  68 65 6c 6c 6f 2c 20 77  6f 72 6c 64 0a           |hello, world.|

You may run as many instances of listeners or pingers as you would like. Concurrency is handled by the router (or switch).

References

The code in this repository is derived from a Gist created by Andre Fiori

go-multicast's People

Contributors

dmichael avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.