Brian Ruthven - Sun UK wrote: > Some more fine grained solutions, but along the same line of disrupting > the connection around the IP layer: [...] > Gordon Ross wrote: >> I'm designing a test for a program that does automatic reconnect >> when a connection goes away. [The program is smbiod(1M)]. >> I want the connection to go away, ideally in a way that "looks" >> similar to receiving a FIN from the server. I had a thought to >> just "ifconfig down" the network I/F, but that seems crude.
Neither taking an interface (or route) down nor adding an ipfilter entry are really equivalent to FIN. FIN starts an orderly shutdown, which gives you a zero-length read. Timeouts (due to missing routes or dropped packets) end up causing a reset connection -- as though you received RST -- and can result in SIGPIPE, depending on how things play out. If you just don't care, you could use the undocumented TCP_IOC_ABORT_CONN ioctl to abort the connection. A more flexible (and accurate) solution would be to set up a proxy that you can control. Have your program under test connect to the proxy, and have the proxy relay the data to the actual peer. For very simple cases, netcat(1) may do what you want. Just SIGTERM the netcat process to shut down the connection. More elaborate schemes (such as a custom proxy) might be needed to allow you to simulate various sorts of failure modes. Such a proxy might allow you to do other useful things, such as writing a journal for debug purposes or simulating hard-to-create test configurations. Isn't smbiod already integrated? Shouldn't there already be a test suite with error simulations ... ? -- James Carlson 42.703N 71.076W <[email protected]> _______________________________________________ networking-discuss mailing list [email protected]
