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 cmd = "python mcastfwd.py "
46 cmd += ' '.join([iface.address for iface in self.ifaces])
48 def _command_set(self, value):
51 command = property(_command_get, _command_set)
54 class MulticastAnnouncer(application.Application):
56 This application installs a userspace daemon that
57 monitors multicast membership and announces it on all
58 multicast-capable interfaces.
59 This does not usually happen automatically on PlanetLab slivers.
61 def __init__(self, *p, **kw):
62 super(MulticastAnnouncer, self).__init__(*p, **kw)
64 self.sources = ' '.join([
65 os.path.join( os.path.dirname(__file__),
66 "scripts", "mcastfwd.py" ),
67 ipaddr2.__file__.replace('.pyc','.py').replace('.pyo','.py'),
72 self.depends = "python"
77 def _command_get(self):
79 "python mcastfwd.py -A %s"
80 ) % ( ' '.join([iface.address for iface in self.ifaces]), )
81 def _command_set(self, value):
84 command = property(_command_get, _command_set)
86 class MulticastRouter(application.Application):
88 This application installs a userspace daemon that
89 monitors multicast membership and announces it on all
90 multicast-capable interfaces.
91 This does not usually happen automatically on PlanetLab slivers.
97 os.path.join( os.path.dirname(__file__),
98 "scripts", "mrouted-3.9.5-pl.patch" ),
101 'buildDepends' : "byacc gcc make patch",
103 "mkdir -p mrouted && "
104 "echo '3a1c1e72c4f6f7334d72df4c50b510d7 mrouted-3.9.5.tar.bz2' > archive_sums.txt && "
105 "wget -q -c -O mrouted-3.9.5.tar.bz2 ftp://ftp.vmlinux.org/pub/People/jocke/mrouted/mrouted-3.9.5.tar.bz2 && "
106 "md5sum -c archive_sums.txt && "
107 "tar xvjf mrouted-3.9.5.tar.bz2 -C mrouted --strip-components=1 && "
108 "cd mrouted && patch -p1 < ${SOURCES}/mrouted-3.9.5-pl.patch && make"
110 'install' : "cp mrouted/mrouted ${SOURCES}",
112 "while test \\! -e /var/run/mcastrt ; do sleep 1 ; done ; "
113 "echo 'phyint eth0 disable' > ./mrouted.conf ; "
114 "for iface in %(nonifaces)s ; do echo \"phyint $iface disable\" >> ./mrouted.conf ; done ; "
115 "./mrouted -f %(debugbit)s -c ./mrouted.conf"
117 'debugbit' : "-dpacket,igmp,routing,interface,pruning,membership,cache",
121 def __init__(self, *p, **kw):
122 super(MulticastRouter, self).__init__(*p, **kw)
124 self.algorithm = 'dvmrp'
128 def _non_set(self, value):
132 def _gen_get(attribute, self):
133 return self.ALGORITHM_MAP[self.algorithm][attribute]
135 def _command_get(self):
136 command = self.ALGORITHM_MAP[self.algorithm]['command']
137 debugbit = self.ALGORITHM_MAP[self.algorithm]['debugbit']
139 # download rpms and pack into a tar archive
141 'nonifaces' : ' '.join([iface.if_name for iface in self.nonifaces if iface.if_name]),
142 'debugbit' : (debugbit if self.stderr else ""),
144 command = property(_command_get, _non_set)
146 build = property(functools.partial(_gen_get, "build"), _non_set)
147 install = property(functools.partial(_gen_get, "install"), _non_set)
148 sources = property(functools.partial(_gen_get, "sources"), _non_set)
149 depends = property(functools.partial(_gen_get, "depends"), _non_set)
150 buildDepends = property(functools.partial(_gen_get, "buildDepends"), _non_set)