• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    C
  • License
    ISC License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple multicast testing application

m c j o i n - tiny multicast testing tool

License Badge GitHub Status Coverity Status

mcjoin(1) is a simple and easy-to-use tool to test IPv4 and IPv6 multicast, featuring:

  • a multicast generator (server)
  • a multicast data sink (client)
  • support for join/send to one or more groups
  • support for both any source and source specific multicast:
    • ASM (*,G)
    • SSM (S,G)
  • support for both IPv4 & IPv6
  • support for the following operating systems:
    • Linux (GLIBC, musl libc)
    • FreeBSD
    • Apple macOS
    • OpenSolaris/Illumos
  • no support for the following due to lack of RFC3678 support:
    • NetBSD
    • OpenBSD

latest release available here: https://github.com/troglobit/mcjoin/releases

example

this is a fairly odd example, joining multiple ipv6 asm groups and a single ipv4 ssm group. the purpose is only to show that it's possible.

mcjoin ff2e::42 ff2e::43 ff2e::44 ff2e::45 225.1.2.3

mcjoin receiver

the sender needs to have an ipv6 (and ipv4) address on the egressing interface. here the system only has an ipv6 address.

mcjoin -s ff2e::42

mcjoin sender

by default, mcjoin use the ipv4 group 225.1.2.3 (which is very easy to spot also when translated to mac multicast, RFC1112). however, for testing purposes you may want to instead use the MCAST_TEST_NET from RFC5771, 233.252.0.0/24, or possibly test group 232.43.211.234, UDP port 4321, as defined in this IETF draft.

for testing IPv6 you can use ff2e::42. for ipv6 groups the ipv6 address of the outbound interface will be used.

remember: to set ipv4 and/or ipv6 address on the outbound interface!

usage

without any arguments mcjoin defaults to act as a receiver, performing an IPv4 ASM join (*,G) of group 225.1.2.3, UDP port 1234. to act as a sender of the same group and port, add -s to the command line.

$ mcjoin -h

Usage: mcjoin [-dhjosv] [-c COUNT] [-f MSEC] [-i IFACE] [-l LEVEL]
              [-p PORT] [-t TTL] [-w SEC]
              [[SOURCE,]GROUP0 .. [SOURCE,]GROUPN | [SOURCE,]GROUP+NUM]

Options:
  -b BYTES    Payload in bytes over IP/UDP header (42 bytes), default: 100
  -c COUNT    Stop sending/receiving after COUNT number of packets
  -d          Run as daemon in background, output except progress to syslog
  -f MSEC     Frequency, poll/send every MSEC milliseconds, default: 100
  -h          This help text
  -i IFACE    Interface to use for sending/receiving multicast, default: eth0
  -j          Join groups, default unless acting as sender
  -l LEVEL    Set log level; none, notice*, debug
  -o          Old (plain/ordinary) output, no fancy progress bars
  -p PORT     UDP port number to listen to, default: 1234
  -s          Act as sender, sends packets to select groups
  -t TTL      TTL to use when sending multicast packets, default 1
  -v          Display program version
  -w SEC      Initial wait before opening sockets
  -W SEC      Timeout, in seconds, before mcjoin exits

Bug report address : https://github.com/troglobit/mcjoin/issues
Project homepage   : https://github.com/troglobit/mcjoin/

the SOURCE argument is optional, but when used it must be of the same address family as the group. to join multiple groups, either list them all on the command line, separated with space, or use the +NUM syntax. at the moment max 2048 groups can be joined.

troubleshooting

the multicast producer, mcjoin -s, can send without a default route, but the sink (your receiver) need a net route back to the sender (or a default route), or reverse-path filtering (RPF) disabled to be able to receive the UDP stream. the sink will be able to start without an IP address or route, as long as the interface is UP and allows MULTICAST, the IGMP or MLD join frames will also be sent while you wait for an address+route, but the kernel will (likely) not forward any frames to mcjoin even though it may be arriving at the interface if you check with tcpdump.

in particular, this issue will arise if you run mcjoin in isolated network namespaces in Linux. e.g.

ip netns add sink
ip link set eth2 netns sink
ip netns exec sink /bin/bash
ip address add 127.0.0.1/8 dev lo
ip link set lo up
ip link set eth2 name eth0
ip address add 10.0.0.42/24 dev eth0
ip link set eth0 up
ip route add default via 10.0.0.1
mcjoin

depending on the route setup, and number of interfaces on a multihomed system, you may also need to verify that you don't have strict reverse path filtering (RPF) enabled. on Linux rp_filter can be set to either 0 (no filtering), 1 (strict), or 2 (loose filtering), the latter is the most common for distributions today. the difference between 1 and 2 is that 1 (strict) checks for the best route, while 2 checks for any route back to the sender. see RFC3704 for more on reverse path filtering.

caveat

usually there is a limit of 20 group joins per socket in UNIX, this is the IP_MAX_MEMBERSHIPTS define. on Linux this can be tweaked using a /proc setting:

echo 40 > /proc/sys/net/ipv4/igmp_max_memberships

mcjoin has a different approach, it opens a unique socket per each group to join and for each socket disables the odd IP_MULTICAST_ALL socket option, which is enabled by default. Citing the Linux ip(7) man page, emphasis added:

IP_MULTICAST_ALL (since Linux 2.6.31)

This option can be used to modify the delivery policy of multicast messages to sockets bound to the wildcard INADDR_ANY address. The argument is a boolean integer (defaults to 1). If set to 1, the socket will receive messages from all the groups that have been joined globally on the whole system. Otherwise, it will deliver messages only from the groups that have been explicitly joined (for example via the IP_ADD_MEMBERSHIP option) on this particular socket.

the same applies to ipv6(7), although the IPV6_MULTICAST_ALL socket option has only existed since Linux 4.20.

hence, by default all multicast applications in UNIX will receive all multicast frames from all groups joined by all other applications on the same system ...

... which IMO is a weird default since multicast by default is opt-in, not opt-out, which is what POSIX makes it. OK, maybe it's not mandated by POSIX, and (unregulated) multicast is akin to broadcast, but still! I bet most developer's don't know about this.

testing on the same machine

in many cases while using mcjoin for testing networking equipment, you need to use at least two local network interfaces (nics): one acting as multicast sender and one as receiver. (often you need multiple sender interfaces, which can be physical, virtual or vlan interfaces.)

        .-------.
        |       |
    .---+  dut  +---.
    |   |       |   |
    |   '-------'   |
    |               |
.- eth0 ---------- eth1 -.
|                        |
|           pc           |
|                        |
'------------------------'

to get this to work on linux you need to disable the rp_filter and enable accept_local sysctl settings for the involved interfaces. here is an example of how to adjust this for all interfaces. use with care, this can cause a lot of other problems if you use the same pc for other purposes as well:

$ cd /etc/sysctl.d/
$ cat 10-network-security.conf
# Allow receiving IP packets from local interfaces, useful for testing
# rigs where looping packets via networking infrastructure.
net.ipv4.conf.default.accept_all=1
net.ipv4.conf.all.accept_all=1

# Disable Source Address Verification in all interfaces to, usually set
# to 1 to prevent some spoofing attacks.  But for a testing rig this is
# usually the source of many woes, in particular for multicast testing.
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

build & install

the GNU Configure & Build system use /usr/local as the default install prefix. for most use-cases this is fine, but if you want to change this to /usr use the --prefix=/usr configure option:

$ ./configure --prefix=/usr
$ make -j5
$ sudo make install-strip

building from git

if you want to contribute, or simply just try out the latest but unreleased features, then you need to know a few things about the GNU Configure & Build system:

  • configure.ac and a per-directory Makefile.am are key files
  • configure and Makefile.in are generated from autogen.sh, they are not stored in GIT but automatically generated for the release tarballs
  • Makefile is generated by configure script

to build from GIT; clone the repository and run the autogen.sh script. this requires automake and autoconf to be installed on your system. (if you build from a released tarball you don't need them.)

git clone https://github.com/troglobit/mcjoin.git
cd mcjoin/
./autogen.sh
./configure && make
sudo make install-strip

More Repositories

1

inadyn

In-a-Dyn is a dynamic DNS client with multiple SSL/TLS library support
C
782
star
2

finit

Fast init for Linux. Cookies included
C
576
star
3

redir

A TCP port redirector for UNIX
C
349
star
4

mg

Micro (GNU) Emacs-like text editor ❀️ public-domain
C
293
star
5

editline

A small replacement for GNU readline() for UNIX
C
254
star
6

libuev

Lightweight event loop library for Linux epoll() family APIs
C
218
star
7

smcroute

Static multicast routing for UNIX
C
216
star
8

pimd

PIM-SM/SSM multicast routing for UNIX and Linux
C
194
star
9

watchdogd

Advanced system monitor & process supervisor for Linux
C
193
star
10

uftpd

FTP/TFTP server for Linux that just worksβ„’
C
162
star
11

merecat

Small and made-easy HTTP/HTTPS server based on Jef Poskanzer's thttpd
C
129
star
12

tetris

Micro Tetrisβ„’, based on the 1989 IOCCC Obfuscated Tetris by John Tromp
C
107
star
13

uredir

A UDP port redirector for UNIX
C
87
star
14

myLinux

myLinux is an embedded operating system based on Buildroot and Finit
Shell
73
star
15

sysklogd

BSD syslog daemon with syslog()/syslogp() API replacement for Linux, RFC3164 + RFC5424
C
71
star
16

mtools

Tools for multicast testing (msend and mreceive). I do however recommend you try out mcjoin(!) or mping instead.
C
69
star
17

mrouted

The original DVMRP (dynamic multicast routing) implementation for UNIX
C
65
star
18

mini-snmpd

A minimal SNMP agent implementation
C
63
star
19

netcalc

Simplified clone of sipcalc with ipcalc looks
C
60
star
20

xplugd

Monitor, keyboard, and mouse plug/unplug helper for X
C
59
star
21

libite

That missing frog DNA you've been looking for
C
58
star
22

ssdp-responder

SSDP responder for UNIX systems that gives you an InternetGatewayDevice icon in Windows :)
C
53
star
23

mdnsd

Jeremie Miller's original mdnsd
C
49
star
24

sntpd

sntpd is a fork of Larry Doolittle's ntpclient with added daemon, syslog, and IPv6 support
C
42
star
25

adventure

Classic Colossal Cave Adventure
C
42
star
26

omping

Open Multicast Ping (omping) is a tool for testing IPv4/IPv6 multicast connectivity on a LAN.
C
33
star
27

snake

Micro Snake, based on Simon Huggins snake game.
C
30
star
28

pok3r-layouts

Vortex POK3R keyboard layouts for Linux, Windows and OS X/macOS. Based on:
28
star
29

rfctl

Linux driver and control tool for 433 MHz communication on Raspberry Pi
C
25
star
30

sun

Simple library and application that shows sunset and sunrise based on your latitude,longitude
C
23
star
31

jush

just give me a unix shell
C
22
star
32

lipify

C API for http://ipify.org
C
19
star
33

pim6sd

PIM for IPv6 sparse mode daemon
C
19
star
34

tinyroot

Small busybox based embedded Linux root file system
Makefile
17
star
35

mping

A simple multicast ping program
C
17
star
36

pimd-dense

Continuation of the original pimd-dense from 1998-1999, gaps filled with frog DNA from pimd
C
14
star
37

pev

Portable Event Library
C
14
star
38

libicmp

Very simple library for sending and receiving ICMP datagrams.
C
13
star
39

backlight

Very simple program to control the backlight brightness of a laptop
C
13
star
40

getty

Minix getty
C
10
star
41

pacman

UNIX pacman game by Dave Nixon, AGS Computers Inc. (1981) with curses support by Mark Horton (1982)
C
10
star
42

uget

Really stupid get-file-over-http program/function
Shell
10
star
43

toolbox

Misc. home brewed code, free to use under GPL/MIT/ISC, see each snippet for license.
C
9
star
44

mrdisc

Stand alone UNIX implementation of RFC4286 Multicast Router Discovery Protocol
C
9
star
45

uemacs

MicroEMACS by Dave Conroy
C
8
star
46

aliens

UNIX aliens game by Jude Miller, Cambridge (1979) with curses support by Mark Horton (1981)
C
7
star
47

nlmon

Simple example of how to use libnl and libev to monitor kernel netlink events
C
7
star
48

quagga

Westermo Quagga. See security/0.99.17 branch for ported CVE fixes and westermo/0.99.17 for patches on top of that. For more information, see the Wiki.
C
7
star
49

keepalived

Health-checking for LVS and high availability
C
6
star
50

ttinfo

Display information about a process, group or tty
C
6
star
51

awesome-config

My awesome window manager configuration
Lua
5
star
52

finit-plugins

Plugin Repository for Finit
C
5
star
53

zoo

public domain zoo archive tool
C
5
star
54

logit

tiny log helper
C
5
star
55

MicroEMACS

MicroEMACS v3.6 by Dave Conroy and Daniel Lawrence from 1986. Free in the public domain.
C
5
star
56

cx

Small wrapper for basic lxc tasks
Shell
5
star
57

awesome-redshift

Ryan Young's small, simple lua library for interfacing the Awesome window manager with redshift
Lua
5
star
58

crobots

CROBOTS is a programming game, for (aspiring) programmers
C
5
star
59

gul

The one true GUL editor!
C
5
star
60

awesome-plain

Plain barebones AwesomeWM setup
Lua
4
star
61

usbctl

A user space tool to operate on USB devices.
C
4
star
62

mctools

Collection of (old) multicast tools
C
4
star
63

deb

Signing key(s) for .deb repository
3
star
64

booz

Zoo Extractor/Lister by Rahul Dhesi
C
3
star
65

sniffer

sniff packets from interface store in db for analysis
C
3
star
66

zroute

Very simple command line client for managing Zebra static routes from the command line. Useful if Zebra is your route manager and you want your DHCP client, or PPPoE client, to set default gateway dynamically via Zebra instead of as kernel routes.
C
3
star
67

libc-chaos

Emit random errors when calling libc functions to emulate an unstable underlying system
C
3
star
68

misc

Misc. helpers, in the public domain
Makefile
2
star
69

alpine-qemu-image

Create bootable Qemu images fro Alpine Linux ISO
Shell
2
star
70

ns

Example of how to use getaddrinfo()
C
2
star
71

awesome-light

Lua library for controlling screen and keyboard brightness from Awesome WM
Lua
2
star
72

plotty

Library for text terminal plotter
C
2
star
73

klish-plugin-sysrepo

Mirror of Serj Kalichev's klish plugins for sysrepo
C
2
star
74

faux

Mirror of Serj Kalichev's auxillary functions library
C
2
star
75

troglobit.github.io

Personal website and blog
CSS
2
star
76

demo

Collection of ASCII art demos
C
1
star
77

ubot

very small and stupid irc bot
C
1
star
78

awesome

My awesome-copycats adaptions
Lua
1
star
79

logrun

An event-based, regexp-triggered, job runner ...
Perl
1
star
80

klish

Mirror of Serj Kalichev's klish
C
1
star
81

br2-finit-demo

Demo of Finit (FastInit) in Buildroot
Makefile
1
star
82

zephyr-uart-test

Playground for the Zephyr UART
C
1
star
83

busybox-builder

busybox defconfig++ binaries
Shell
1
star
84

bridged

Linux bridge helper daemon
C
1
star
85

weatherd

Hackish weather data logger for my homemade Raspberry Pi based weather station
C
1
star