aboutsummaryrefslogtreecommitdiff
path: root/rumba/storyboard.py
diff options
context:
space:
mode:
Diffstat (limited to 'rumba/storyboard.py')
-rw-r--r--rumba/storyboard.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/rumba/storyboard.py b/rumba/storyboard.py
index ea0c51e..61dd8cc 100644
--- a/rumba/storyboard.py
+++ b/rumba/storyboard.py
@@ -34,6 +34,7 @@ import math
import os
import random
import time
+import uuid
import rumba.model as model
import rumba.ssh_support as ssh_support
@@ -821,6 +822,39 @@ class StoryBoard(SBEntity):
buffer = StringIO(string)
self.parse_script(buffer, clean)
+ def capture_traffic(self, start, end, node, dif):
+ """
+ Captures the traffic of an interface on a certain node.
+
+ :param start: The time to start capturing.
+ :param end: The time to stop capturing.
+ :param node: The node to capture on.
+ :param dif: The Shim Ethernet DIF of the node, Rumba
+ automatically resolves the correct interface.
+ """
+ for ipcp in dif.ipcps:
+ if ipcp.node is not node:
+ continue
+ # In case tcpdump is not present, this assumes a testbed
+ # with Ubuntu/Debian just like the rest of installation
+ if not node.has_tcpdump:
+ ssh_support.aptitude_install(self.experiment.testbed,
+ node, ["tcpdump"])
+ node.has_tcpdump = True
+
+ # Create random string
+ pcap_file = node.name + '_' + dif.name + '_' + \
+ str(uuid.uuid4())[0:4] + ".pcap"
+
+ tcpd_client = Client(ap="tcpdump", options="-i %s -w %s" \
+ % (ipcp.ifname, pcap_file))
+ duration = end - start
+ cb = functools.partial(node.fetch_file, pcap_file,
+ self.experiment.log_dir, sudo=True)
+ action = functools.partial(self.run_client, tcpd_client,
+ duration=duration, node=node,
+ callback = cb)
+ self._script.add_event(Event(action, ev_time=start))
class Event(object):