You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
// SWP3.java (C) I. A. Robin, K. J. Turner 08/03/06
|
|
|
|
package protocol;
|
|
|
|
import java.util.*;
|
|
import support.*;
|
|
|
|
public class SWP3 extends Protocol {
|
|
|
|
private int maxSeq = 7;
|
|
private int winSize = 3;
|
|
private SWP3Sender sender;
|
|
private SWP3Receiver receiver;
|
|
|
|
public SWP3() {
|
|
medium = new Medium();
|
|
sender = new SWP3Sender(maxSeq, winSize, medium);
|
|
receiver = new SWP3Receiver(maxSeq, winSize, medium);
|
|
sender.setPeer(receiver);
|
|
receiver.setPeer(sender);
|
|
entities = new Vector<ProtocolEntity>();
|
|
entities.addElement(sender);
|
|
entities.addElement(medium);
|
|
entities.addElement(receiver);
|
|
}
|
|
|
|
public void setParameter(String param, String value) {
|
|
super.setParameter(param, value);
|
|
try {
|
|
if (param.equals("maxSeq")) {
|
|
maxSeq = Integer.parseInt(value);
|
|
sender.setMaxSeq(maxSeq);
|
|
receiver.setMaxSeq(maxSeq);
|
|
}
|
|
else if (param.equals("winSize")) {
|
|
winSize = Integer.parseInt(value);
|
|
sender.setWindowSize(winSize);
|
|
receiver.setWindowSize(winSize);
|
|
}
|
|
}
|
|
catch (NumberFormatException e) {}
|
|
}
|
|
|
|
}
|