bridge: make pass-through the default
Setting only latency options is a pain since every fault must
be disabled on the command line. Instead, by default start
as a standard bridge without any fault injection.
@@ -193,19 +193,19 @@ type connFaultFunc func(*bridgeConn)
func main() {
var cfg config
- flag.BoolVar(&cfg.delayAccept, "delay-accept", true, "delays accepting new connections")
- flag.BoolVar(&cfg.resetListen, "reset-listen", true, "resets the listening port")
-
- flag.Float64Var(&cfg.connFaultRate, "conn-fault-rate", 0.25, "rate of faulty connections")
- flag.BoolVar(&cfg.immediateClose, "immediate-close", true, "close after accept")
- flag.BoolVar(&cfg.blackhole, "blackhole", true, "reads nothing, writes go nowhere")
- flag.BoolVar(&cfg.timeClose, "time-close", true, "close after random time")
- flag.BoolVar(&cfg.writeRemoteOnly, "write-remote-only", true, "only write, no read")
- flag.BoolVar(&cfg.readRemoteOnly, "read-remote-only", true, "only read, no write")
- flag.BoolVar(&cfg.randomBlackhole, "random-blackhole", true, "blackhole after data xfer")
- flag.BoolVar(&cfg.corruptReceive, "corrupt-receive", true, "corrupt packets received from destination")
- flag.BoolVar(&cfg.corruptSend, "corrupt-send", true, "corrupt packets sent to destination")
- flag.BoolVar(&cfg.reorder, "reorder", true, "reorder packet delivery")
+ flag.BoolVar(&cfg.delayAccept, "delay-accept", false, "delays accepting new connections")
+ flag.BoolVar(&cfg.resetListen, "reset-listen", false, "resets the listening port")
+
+ flag.Float64Var(&cfg.connFaultRate, "conn-fault-rate", 0.0, "rate of faulty connections")
+ flag.BoolVar(&cfg.immediateClose, "immediate-close", false, "close after accept")
+ flag.BoolVar(&cfg.blackhole, "blackhole", false, "reads nothing, writes go nowhere")
+ flag.BoolVar(&cfg.timeClose, "time-close", false, "close after random time")
+ flag.BoolVar(&cfg.writeRemoteOnly, "write-remote-only", false, "only write, no read")
+ flag.BoolVar(&cfg.readRemoteOnly, "read-remote-only", false, "only read, no write")
+ flag.BoolVar(&cfg.randomBlackhole, "random-blackhole", false, "blackhole after data xfer")
+ flag.BoolVar(&cfg.corruptReceive, "corrupt-receive", false, "corrupt packets received from destination")
+ flag.BoolVar(&cfg.corruptSend, "corrupt-send", false, "corrupt packets sent to destination")
+ flag.BoolVar(&cfg.reorder, "reorder", false, "reorder packet delivery")
flag.StringVar(&cfg.txDelay, "tx-delay", "0", "duration to delay client transmission to server")
flag.StringVar(&cfg.rxDelay, "rx-delay", "0", "duration to delay client receive from server")
@@ -287,6 +287,10 @@ func main() {
connFaults = append(connFaults, f)
}
+ if len(connFaults) > 1 && cfg.connFaultRate == 0 {
+ log.Fatal("connection faults defined but conn-fault-rate=0")
+ }
+
var disp dispatcher
if cfg.reorder {
disp = newDispatcherPool()
@@ -302,7 +306,7 @@ func main() {
}
r := rand.Intn(len(connFaults))
- if rand.Intn(100) > int(100.0*cfg.connFaultRate) {
+ if rand.Intn(100) >= int(100.0*cfg.connFaultRate) {
r = 0
}
