Adding a new rule for limiting node bandwidth, minor fix to rule for limiting link...
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 6 Nov 2009 20:50:45 +0000 (20:50 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 6 Nov 2009 20:50:45 +0000 (20:50 +0000)
sfatables/processors/max_link_kbps.xsl
sfatables/processors/max_node_kbps.xsl [new file with mode: 0644]
sfatables/targets/RESTRICT_SLICE_PROP.xml

index 71d0abe..59a6741 100644 (file)
       
   <!-- Fill in missing kbps values --> 
   <xsl:template match="LinkSpec[not(kbps)]">
-    <LinkSpec>
+      <xsl:copy>
       <xsl:copy-of select="*"/>
       <kbps><xsl:value-of select="$max-link-kbps"/></kbps>
-    </LinkSpec>
+  </xsl:copy>
   </xsl:template>
   
   <xsl:template match="sfatables-input"/>
diff --git a/sfatables/processors/max_node_kbps.xsl b/sfatables/processors/max_node_kbps.xsl
new file mode 100644 (file)
index 0000000..d7c0060
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <!-- Magic sauce copied from a manual. This fragment basically
+    copies everything except for stuff that explicitly matches with
+    the templates defined below. In the case of such a match, the
+    matched node is treated differently.-->
+  <xsl:template match="@* | node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@* | node()"/>
+    </xsl:copy>
+  </xsl:template>
+  <!-- End of magic sauce -->
+
+  <!-- Read in the value of the argument. -->
+  <xsl:variable name="max-node-kbps" select="//RSpec//target-context/argument[name='max-node-kbps']/value"/>
+
+  <!-- Modify NodeSpec for which kbps > max-link-kbps -->
+  <xsl:template match="NodeSpec/max_rate">
+      <xsl:choose>
+          <xsl:when test=". &gt; $max-node-kbps">
+              <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
+          </xsl:when>
+          <xsl:otherwise>
+              <xsl:copy-of select="."/>
+          </xsl:otherwise>
+      </xsl:choose>
+  </xsl:template>
+      
+  <!-- Fill in missing kbps values --> 
+  <xsl:template match="NodeSpec[not(max_rate)]">
+      <xsl:copy>
+          <xsl:copy-of select="*"/>
+          <max_rate><xsl:value-of select="$max-node-kbps"/></max_rate>
+      </xsl:copy>
+  </xsl:template>
+  
+  <xsl:template match="sfatables-input"/>
+</xsl:stylesheet>
index 8e2b7af..e37fc6e 100644 (file)
@@ -1,5 +1,14 @@
 <target name="RESTRICT_SLICE_PROP">
     <!-- The context is empty, since this target does not require any input from SFA -->
+    <rule element="node">
+    <context select=""/>
+        <argument>
+            <name>max-node-kbps</name>
+            <help>Maximum node bandwidth in kilobytes per second.</help>
+            <operand>kbps2</operand>
+        </argument>
+    <processor filename="max_node_kbps.xsl"/>
+    </rule>
     <rule element="link">
     <context select=""/>
         <argument>
@@ -9,4 +18,4 @@
         </argument>
     <processor filename="max_link_kbps.xsl"/>
     </rule>
-</target>
+    </target>