2 # -*- coding: utf-8 -*-
4 from constants import TESTBED_ID
11 import nepi.util.server as server
12 import nepi.util.ipaddr2 as ipaddr2
18 class MulticastForwarder(application.Application):
20 This application installs a userspace packet forwarder
21 that, when connected to a node, filters all packets
22 flowing through multicast-capable virtual interfaces
23 and applies custom-specified routing policies
25 def __init__(self, *p, **kw):
26 super(MulticastForwarder, self).__init__(*p, **kw)
28 self.sources = ' '.join([
29 os.path.join( os.path.dirname(__file__),
30 "scripts", "mcastfwd.py" ),
31 ipaddr2.__file__.replace('.pyc','.py').replace('.pyo','.py'),
36 self.depends = "python"
38 # Initialized when connected
42 def _command_get(self):
43 # canonical representation of dependencies
44 depends = ' '.join( sorted( (self.depends or "").split(' ') ) )
46 # download rpms and pack into a tar archive
48 "python mcastfwd.py %s"
49 ) % ( ' '.join([iface.address for iface in self.ifaces]), )
50 def _command_set(self, value):
53 command = property(_command_get, _command_set)
56 class MulticastAnnouncer(application.Application):
58 This application installs a userspace daemon that
59 monitors multicast membership and announces it on all
60 multicast-capable interfaces.
61 This does not usually happen automatically on PlanetLab slivers.
63 def __init__(self, *p, **kw):
64 super(MulticastAnnouncer, self).__init__(*p, **kw)
66 self.sources = ' '.join([
67 os.path.join( os.path.dirname(__file__),
68 "scripts", "mcastfwd.py" ),
69 ipaddr2.__file__.replace('.pyc','.py').replace('.pyo','.py'),
74 self.depends = "python"
79 def _command_get(self):
80 # canonical representation of dependencies
81 depends = ' '.join( sorted( (self.depends or "").split(' ') ) )
83 # download rpms and pack into a tar archive
85 "python mcastfwd.py -A %s"
86 ) % ( ' '.join([iface.address for iface in self.ifaces]), )
87 def _command_set(self, value):
90 command = property(_command_get, _command_set)
92 class MulticastRouter(application.Application):
94 This application installs a userspace daemon that
95 monitors multicast membership and announces it on all
96 multicast-capable interfaces.
97 This does not usually happen automatically on PlanetLab slivers.
103 os.path.join( os.path.dirname(__file__),
104 "scripts", "mrouted-3.9.5-pl.patch" ),
107 'buildDepends' : "byacc gcc make patch",
109 "mkdir -p mrouted && "
110 "echo '3a1c1e72c4f6f7334d72df4c50b510d7 mrouted-3.9.5.tar.bz2' > archive_sums.txt && "
111 "wget -q -c -O mrouted-3.9.5.tar.bz2 ftp://ftp.vmlinux.org/pub/People/jocke/mrouted/mrouted-3.9.5.tar.bz2 && "
112 "md5sum -c archive_sums.txt && "
113 "tar xvjf mrouted-3.9.5.tar.bz2 -C mrouted --strip-components=1 && "
114 "cd mrouted && patch -p1 < ${SOURCES}/mrouted-3.9.5-pl.patch && make"
116 'install' : "cp mrouted/mrouted ${SOURCES}",
118 "while test \\! -e /var/run/mcastrt ; do sleep 1 ; done ; "
119 "echo 'phyint eth0 disable' > ./mrouted.conf ; "
120 "for iface in %(nonifaces)s ; do echo \"phyint $iface disable\" >> ./mrouted.conf ; done ; "
121 "./mrouted -f %(debugbit)s -c ./mrouted.conf"
123 'debugbit' : "-dpacket,igmp,routing,interface,pruning,membership,cache",
127 def __init__(self, *p, **kw):
128 super(MulticastRouter, self).__init__(*p, **kw)
130 self.algorithm = 'dvmrp'
134 def _non_set(self, value):
138 def _gen_get(attribute, self):
139 return self.ALGORITHM_MAP[self.algorithm][attribute]
141 def _command_get(self):
142 command = self.ALGORITHM_MAP[self.algorithm]['command']
143 debugbit = self.ALGORITHM_MAP[self.algorithm]['debugbit']
145 # download rpms and pack into a tar archive
147 'nonifaces' : ' '.join([iface.if_name for iface in self.nonifaces]),
148 'debugbit' : (debugbit if self.stderr else ""),
150 command = property(_command_get, _non_set)
152 build = property(functools.partial(_gen_get, "build"), _non_set)
153 install = property(functools.partial(_gen_get, "install"), _non_set)
154 sources = property(functools.partial(_gen_get, "sources"), _non_set)
155 depends = property(functools.partial(_gen_get, "depends"), _non_set)
156 buildDepends = property(functools.partial(_gen_get, "buildDepends"), _non_set)