Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/examples/rump/virtual_ip_router amazing grep, how swee...



details:   https://anonhg.NetBSD.org/src/rev/817085199858
branches:  trunk
changeset: 753438:817085199858
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Mar 29 02:11:14 2010 +0000

description:
amazing grep, how sweet the find
that saved a hack like me
script once was lost but now it's found
was -x, but now I sh

diffstat:

 share/examples/rump/virtual_ip_router/README.txt      |   5 +-
 share/examples/rump/virtual_ip_router/startrouters.sh |  68 +++++++++++++++++++
 2 files changed, 70 insertions(+), 3 deletions(-)

diffs (91 lines):

diff -r 1bdf25f5ee37 -r 817085199858 share/examples/rump/virtual_ip_router/README.txt
--- a/share/examples/rump/virtual_ip_router/README.txt  Mon Mar 29 02:01:47 2010 +0000
+++ b/share/examples/rump/virtual_ip_router/README.txt  Mon Mar 29 02:11:14 2010 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: README.txt,v 1.1 2010/03/29 02:01:47 pooka Exp $
+       $NetBSD: README.txt,v 1.2 2010/03/29 02:11:14 pooka Exp $
 
 Using rump it is possible to build a router test setup consisting
 of thousands of NetBSD IP stacks within a single host OS, one
@@ -92,8 +92,7 @@
 ./a.out 10.0.253.1 10.0.253.255 /tmp/rumpshm_253 10.0.253.2 10.0.255.1 10.0.255.
 255 /tmp/rumpshm_255 0
 
-Unfortunately I lost script used to produce that, but the algorithm
-is quickly obvious.
+(see startrouters.sh for a script to produce that output)
 
 Easy but slightly more interesting setups, such as a M^N matrix
 (hyper-matrix?) are also possible, but left as an exercise to the
diff -r 1bdf25f5ee37 -r 817085199858 share/examples/rump/virtual_ip_router/startrouters.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/examples/rump/virtual_ip_router/startrouters.sh     Mon Mar 29 02:11:14 2010 +0000
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+#      $NetBSD: startrouters.sh,v 1.1 2010/03/29 02:11:14 pooka Exp $
+#
+
+dummy=
+amp="&"
+LIF="10.0.XXX.1"
+LBCAST="10.0.XXX.255"
+LFILE="/tmp/rumpshm_XXX"
+LROUTE="10.0.XXX.2"
+
+RIF="10.0.YYY.2"
+RBCAST="10.0.YYY.255"
+RFILE="/tmp/rumpshm_YYY"
+RROUTE="10.0.YYY.1"
+
+die ()
+{
+
+       echo $1
+       exit 1
+}
+
+[ $# != "1" ] && die "usage: script.sh nrouters"
+n=${1}
+
+[ "$n" -lt "1" ] && die "n must be between 1 and 254"
+[ "$n" -gt "254" ] && die "n must be between 1 and 254"
+
+pkill a.out
+rm /tmp/rumpshm_*
+rm -f cmds
+
+i=1
+ip=0
+while [ ${i} -le ${n} ]
+do
+       lif=`echo ${LIF} | sed "s/XXX/${ip}/"`
+       lbcast=`echo ${LBCAST} | sed "s/XXX/${ip}/"`
+       lfile=`echo ${LFILE} | sed "s/XXX/${ip}/"`
+       lroute=`echo ${LROUTE} | sed "s/XXX/${ip}/"`
+
+       rif=`echo ${RIF} | sed "s/YYY/${i}/"`
+       rbcast=`echo ${RBCAST} | sed "s/YYY/${i}/"`
+       rfile=`echo ${RFILE} | sed "s/YYY/${i}/"`
+       rroute=`echo ${RROUTE} | sed "s/YYY/${i}/"`
+
+       if [ $i = 1 ]
+       then
+               lroute="0"
+       fi
+
+       if [ $i = $n ]
+       then
+               rif="10.0.255.1"
+               rbcast="10.0.255.255"
+               rfile="/tmp/rumpshm_255"
+               rroute="0"
+       fi
+
+       echo ./a.out ${lif} ${lbcast} ${lfile} ${lroute} ${rif} ${rbcast} ${rfile} ${rroute} >> cmds
+
+       ip=${i}
+       i=$((i+1))
+done
+
+#echo ./specialpint send tcp 10.0.255.10 >> cmds



Home | Main Index | Thread Index | Old Index