public static void main(String[] args) throws Exception {
		// process command line arguments
		if (args.length < 5)  {
			System.out.println("usage: TestRdt myIp myPort " +
				"wSize timeout [ debug ] " +
				"[ discProb delta runLength ] " +
				"[ peerIp peerPort ]");
			System.exit(1);
		}
		InetAddress myIp = InetAddress.getByName(args[0]);
		int myPort = Integer.parseInt(args[1]);
		int wSize = Integer.parseInt(args[2]);
		double timeout = Double.parseDouble(args[3]);

		boolean debug = false; int nextArg = 4;
		if (args.length > nextArg && args[nextArg].equals("debug")) {
			debug = true; nextArg++;
		}
		double discProb = 0;
		if (args.length > nextArg) 
			discProb = Double.parseDouble(args[nextArg++]);
		double delta = 0;
		if (args.length > nextArg) 
			delta = Double.parseDouble(args[nextArg++]);
		double runLength = 0;
		if (args.length > nextArg) {
			runLength = Double.parseDouble(args[nextArg++]);
		}
		InetSocketAddress peerAdr = null;
		if (args.length > nextArg+1) 
			peerAdr = new InetSocketAddress(args[nextArg],
				    	Integer.parseInt(args[nextArg+1]));

		try {
			// instantiate components and start their threads
			Substrate sub = new Substrate(myIp,myPort,peerAdr,
						      discProb,debug);
			sub.start();
			Rdt rdt = new Rdt(wSize,timeout,sub);
			rdt.start();
			// delay sending of packets by server, to give client
			// a chance to send the first packet
			if (peerAdr == null) Thread.sleep(2000);
			SrcSnk ss = new SrcSnk(delta,runLength,rdt);
			ss.start();
			// wait for substrate to quit, then stop others
			sub.join(); rdt.stop(); ss.stop();
		} catch(Exception e) {
			System.out.println("TestRdt: exception " + e);
			System.exit(1);
		}

	}