Commit 9128913c authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Léo-Paul Géneau

.

parent de0fc816
......@@ -4,10 +4,11 @@
from __future__ import print_function
import sys, struct, time
import sys, time
from socket import socket, AF_INET, SOCK_DGRAM, IPPROTO_UDP, SOL_SOCKET, \
SO_REUSEADDR, IPPROTO_IP, IP_ADD_MEMBERSHIP, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, \
inet_aton, INADDR_ANY
from struct import pack
from golang import b, u
from golang import sync, context
......@@ -23,7 +24,7 @@ def mjoin_tx(group, port, ttl=2):
sk = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
# set ttl and default destination address (for tx)
sk.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)
sk.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, pack('b', ttl))
sk.connect((group, port))
# so that what we send is received locally as well
......@@ -36,10 +37,10 @@ def mjoin_rx(group, port):
sk = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
sk.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sk.bind(('', port))
sk.bind((group, port))
# join the group (for rx)
mreq = struct.pack("4sl", inet_aton(group), INADDR_ANY)
mreq = pack("4sl", inet_aton(group), INADDR_ANY)
sk.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
return sk
......
#!/bin/bash
# topo B-A-C creates the following network topology:
#
#
# netns=B netns=A netns=C
#
# B --- br0 --- A --- br1 --- C
# b1 a1 a2 c1
#
# should be run under unshare -mrun .
# use nsenter --net={A,B,C} to enter into network namespace of A/B/C.
touch A B C
ip link add br0 type bridge # vlan_filtering 1 mcast_snooping 0
ip link add type a1 veth peer b1
ip link set b1 master br0
ip link set a1 up
ip link set b1 up
ip link set br0 up
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment