hw2: last moment fixes

This commit is contained in:
Claudio Maggioni 2020-05-13 18:15:24 +02:00
parent 822f17e264
commit 56edd49b62
22 changed files with 60 additions and 249 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" default="false" project-jdk-name="13" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="12.0.1" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View file

@ -1,113 +0,0 @@
Siena (Scalable Internet Event Notification Architectures) is a research project aimed at
designing and constructing a generic scalable publish/subscribe event-notification service.
The technical basis of Siena is an innovative type of network service called content-based networking.
Overview
The asynchrony, heterogeneity, and inherent loose coupling that characterize applications in a wide-area
network promote event interaction as a natural design abstraction for a growing class of software systems.
An emerging building block for such systems is an infrastructure called publish/subscribe event notification
service.
Software systems of a significant dimension, especially those that are distributed over a computer network,
are often engineered by means of the integration of components. A promising approach to support component-based
software architectures is the so-called event-based style whereby the interaction of components is modeled with
events. Components emit events to inform other components of a change in their internal state or to request services
from other components. Upon detecting the occurrence of events, components react by executing some actions and possibly
emitting other events. The glue that ties components together in an event-based architecture is an infrastructure that
we call event service. The event service registers the interests of components and then dispatches event notifications
accordingly. The advantage of using an event service instead of other "classical" integration mechanisms
such as direct or remote invocation is that this method increases the degree of de-coupling among components
thus eliminating static dependencies and improving interoperability.
We envision a ubiquitous event notification service accessible from every site on a wide-area network and suitable
for supporting highly distributed applications requiring component interactions ranging in granularity from fine to
coarse. Conceptually, the service is implemented as a network of servers that provide access points to clients. Clients
use the access points to advertise the information about events that they generate and to publish notifications
containing that information. They also use the access points to subscribe for notifications of interest.
The service uses the access points to then notify clients by delivering any notifications of interest. Clearly, an
event notification service complements other general-purpose middleware services, such as point-to-point and multicast
communication mechanisms, by offering a many-to-many communication and integration facility.
Given that the primary purpose of an event notification service is to support notification selection and delivery,
the challenge we face in a wide-area setting is maximizing expressiveness in the selection mechanism without sacrificing
scalability in the delivery mechanism. Expressiveness refers to the ability of the event notification service to provide
a powerful data model with which to capture information about events, to express filters and patterns on notifications
of interest, and to use that data model as the basis for optimizing notification delivery. In terms of scalability,
we are referring not simply to the number of event generators, the number of event notifications, and the number
of notification recipients, but also to the need to discard many of the assumptions made for local-area networks,
such as low latency, abundant bandwidth, homogeneous platforms, continuous and reliable connectivity, and
centralized control.
Intuitively, a simple event notification service that provides no selection mechanism can be reduced to a multicast
routing and transport mechanism for which there are numerous scalable implementations. However, once the service provides
a selection mechanism, then the overall efficiency of the service and its routing of notifications are affected by the
power of the language used to construct notifications and to express filters and patterns. As the power of the language
increases, so does the complexity of the processing. Thus, in practice, scalability and expressiveness are two
conflicting goals that must be traded off.
Siena is an event notification service that we have designed and implemented to maximize both expressiveness and
scalability. A prototype implementation of Siena is available.
People
Siena is primarily the work of Antonio Carzaniga and Alexander L. Wolf. D.S. Rosenblum also made significant
contributions to the initial design of Siena.
Others also contributed directly to the development of Siena. Among them are John Giacomoni, Mauro Caporuscio,
Matthew J. Rutherford, Cyrus P. Hall, Yanyan Wang, Giovanni Toffetti, and Amir Malekpour.
Documents
Articles are available in Portable Document Format (PDF) or PostScript® format and some of them are compressed
with gzip. Downloading any one of these documents indicates that you agree to abide by a copyright notice.
Selected Papers
Design and Evaluation of a Wide-Area Event Notification Service
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
ACM Transactions on Computer Systems, 19(3):332-383, August 2001.
Abstract, BibTeX ref., PDF, DOI
End-to-End Reliability for Best-Effort Content-Based Publish/Subscribe Networks
A. Malekpour, A. Carzaniga, F. Pedone, and G. Toffetti Carughi
In Proceedings of the 5th ACM International Conference on Distributed Event-Based Systems (DEBS 2011). New York, New York, July 2011.
Abstract, BibTeX ref., PDF, DOI
A Routing Scheme for Content-Based Networking
A. Carzaniga, M.J. Rutherford, and A.L. Wolf
Proceedings of IEEE INFOCOM 2004. Hong Kong, China. March 2004.
Abstract, BibTeX ref., PDF, DOI
Forwarding in a Content-Based Network
A. Carzaniga and A.L. Wolf
Proceedings of ACM SIGCOMM 2003. p. 163-174. Karlsruhe, Germany. August 2003.
Abstract, BibTeX ref., PDF, DOI
Design and Evaluation of a Support Service for Mobile, Wireless Publish/Subscribe Applications
M. Caporuscio, A. Carzaniga, and A.L. Wolf
IEEE Transactions on Software Engineering, 29(12):1059-1071, December 2003.
Abstract, BibTeX ref., PDF, DOI
Content-based Networking: A New Communication Infrastructure
A. Carzaniga and A.L. Wolf
In NSF Workshop on an Infrastructure for Mobile and Wireless Systems. Lecture Notes in Computer Science n. 2538 p. 59-68. Springer-Verlag. Scottsdale, Arizona. October 2001.
Abstract, BibTeX ref., PDF
Achieving Expressiveness and Scalability in an Internet-Scale Event Notification Service
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
Nineteenth ACM Symposium on Principles of Distributed Computing (PODC2000). Portland, Oregon, July 2000.
Abstract, BibTeX ref., PDF, DOI
Content-Based Addressing and Routing: A General Model and its Application
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
Technical Report CU-CS-902-00, Department of Computer Science, University of Colorado, January 2000.
Abstract, BibTeX ref., PDF
Architectures for an Event Notification Service Scalable to Wide-area Networks
A. Carzaniga
PhD Thesis. Politecnico di Milano. December, 1998.
Abstract, BibTeX ref., PDF
A Design Framework for Internet-Scale Event Observation and Notification
D.S. Rosenblum and A.L. Wolf
6th European Software Engineering Conference. Lecture Notes in Computer Science 1301, Springer, Berlin, 1997.
Acknowledgments
This work was supported in part by the Air Force Materiel Command, Rome Laboratory, and the Defense Advanced
Research Projects Agency under Contract Numbers F30602-94-C-0253, F30602-97-2-0021, F30602-98-2-0163,
and F30602-99-C-0174; by the Air Force Office of Scientific Research, Air Force Materiel Command, USAF, u
nder grant number F49620-98-1-0061; and by the National Science Foundation under Grant Number CCR-9701973.
The content of the information does not necessarily reflect the position or the policy of the US Governmen
t and no official endorsement should be inferred.
We thank Dennis Heimbigner, Richard S. Hall, and André van der Hoek of the Software Engineering Research Laboratory,
University of Colorado at Boulder (circa 1997), and Giampaolo Cugola, Elisabetta Di Nitto, and Alfonso Fuggetta of
Politecnico di Milano for their contributions to this work.
this page is maintained by Antonio Carzaniga and was updated on September 15, 2019

View file

@ -1,113 +0,0 @@
Siena (Scalable Internet Event Notification Architectures) is a research project aimed at
designing and constructing a generic scalable publish/subscribe event-notification service.
The technical basis of Siena is an innovative type of network service called content-based networking.
Overview
The asynchrony, heterogeneity, and inherent loose coupling that characterize applications in a wide-area
network promote event interaction as a natural design abstraction for a growing class of software systems.
An emerging building block for such systems is an infrastructure called publish/subscribe event notification
service.
Software systems of a significant dimension, especially those that are distributed over a computer network,
are often engineered by means of the integration of components. A promising approach to support component-based
software architectures is the so-called event-based style whereby the interaction of components is modeled with
events. Components emit events to inform other components of a change in their internal state or to request services
from other components. Upon detecting the occurrence of events, components react by executing some actions and possibly
emitting other events. The glue that ties components together in an event-based architecture is an infrastructure that
we call event service. The event service registers the interests of components and then dispatches event notifications
accordingly. The advantage of using an event service instead of other "classical" integration mechanisms
such as direct or remote invocation is that this method increases the degree of de-coupling among components
thus eliminating static dependencies and improving interoperability.
We envision a ubiquitous event notification service accessible from every site on a wide-area network and suitable
for supporting highly distributed applications requiring component interactions ranging in granularity from fine to
coarse. Conceptually, the service is implemented as a network of servers that provide access points to clients. Clients
use the access points to advertise the information about events that they generate and to publish notifications
containing that information. They also use the access points to subscribe for notifications of interest.
The service uses the access points to then notify clients by delivering any notifications of interest. Clearly, an
event notification service complements other general-purpose middleware services, such as point-to-point and multicast
communication mechanisms, by offering a many-to-many communication and integration facility.
Given that the primary purpose of an event notification service is to support notification selection and delivery,
the challenge we face in a wide-area setting is maximizing expressiveness in the selection mechanism without sacrificing
scalability in the delivery mechanism. Expressiveness refers to the ability of the event notification service to provide
a powerful data model with which to capture information about events, to express filters and patterns on notifications
of interest, and to use that data model as the basis for optimizing notification delivery. In terms of scalability,
we are referring not simply to the number of event generators, the number of event notifications, and the number
of notification recipients, but also to the need to discard many of the assumptions made for local-area networks,
such as low latency, abundant bandwidth, homogeneous platforms, continuous and reliable connectivity, and
centralized control.
Intuitively, a simple event notification service that provides no selection mechanism can be reduced to a multicast
routing and transport mechanism for which there are numerous scalable implementations. However, once the service provides
a selection mechanism, then the overall efficiency of the service and its routing of notifications are affected by the
power of the language used to construct notifications and to express filters and patterns. As the power of the language
increases, so does the complexity of the processing. Thus, in practice, scalability and expressiveness are two
conflicting goals that must be traded off.
Siena is an event notification service that we have designed and implemented to maximize both expressiveness and
scalability. A prototype implementation of Siena is available.
People
Siena is primarily the work of Antonio Carzaniga and Alexander L. Wolf. D.S. Rosenblum also made significant
contributions to the initial design of Siena.
Others also contributed directly to the development of Siena. Among them are John Giacomoni, Mauro Caporuscio,
Matthew J. Rutherford, Cyrus P. Hall, Yanyan Wang, Giovanni Toffetti, and Amir Malekpour.
Documents
Articles are available in Portable Document Format (PDF) or PostScript® format and some of them are compressed
with gzip. Downloading any one of these documents indicates that you agree to abide by a copyright notice.
Selected Papers
Design and Evaluation of a Wide-Area Event Notification Service
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
ACM Transactions on Computer Systems, 19(3):332-383, August 2001.
Abstract, BibTeX ref., PDF, DOI
End-to-End Reliability for Best-Effort Content-Based Publish/Subscribe Networks
A. Malekpour, A. Carzaniga, F. Pedone, and G. Toffetti Carughi
In Proceedings of the 5th ACM International Conference on Distributed Event-Based Systems (DEBS 2011). New York, New York, July 2011.
Abstract, BibTeX ref., PDF, DOI
A Routing Scheme for Content-Based Networking
A. Carzaniga, M.J. Rutherford, and A.L. Wolf
Proceedings of IEEE INFOCOM 2004. Hong Kong, China. March 2004.
Abstract, BibTeX ref., PDF, DOI
Forwarding in a Content-Based Network
A. Carzaniga and A.L. Wolf
Proceedings of ACM SIGCOMM 2003. p. 163-174. Karlsruhe, Germany. August 2003.
Abstract, BibTeX ref., PDF, DOI
Design and Evaluation of a Support Service for Mobile, Wireless Publish/Subscribe Applications
M. Caporuscio, A. Carzaniga, and A.L. Wolf
IEEE Transactions on Software Engineering, 29(12):1059-1071, December 2003.
Abstract, BibTeX ref., PDF, DOI
Content-based Networking: A New Communication Infrastructure
A. Carzaniga and A.L. Wolf
In NSF Workshop on an Infrastructure for Mobile and Wireless Systems. Lecture Notes in Computer Science n. 2538 p. 59-68. Springer-Verlag. Scottsdale, Arizona. October 2001.
Abstract, BibTeX ref., PDF
Achieving Expressiveness and Scalability in an Internet-Scale Event Notification Service
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
Nineteenth ACM Symposium on Principles of Distributed Computing (PODC2000). Portland, Oregon, July 2000.
Abstract, BibTeX ref., PDF, DOI
Content-Based Addressing and Routing: A General Model and its Application
A. Carzaniga, D.S. Rosenblum, and A.L. Wolf
Technical Report CU-CS-902-00, Department of Computer Science, University of Colorado, January 2000.
Abstract, BibTeX ref., PDF
Architectures for an Event Notification Service Scalable to Wide-area Networks
A. Carzaniga
PhD Thesis. Politecnico di Milano. December, 1998.
Abstract, BibTeX ref., PDF
A Design Framework for Internet-Scale Event Observation and Notification
D.S. Rosenblum and A.L. Wolf
6th European Software Engineering Conference. Lecture Notes in Computer Science 1301, Springer, Berlin, 1997.
Acknowledgments
This work was supported in part by the Air Force Materiel Command, Rome Laboratory, and the Defense Advanced
Research Projects Agency under Contract Numbers F30602-94-C-0253, F30602-97-2-0021, F30602-98-2-0163,
and F30602-99-C-0174; by the Air Force Office of Scientific Research, Air Force Materiel Command, USAF, u
nder grant number F49620-98-1-0061; and by the National Science Foundation under Grant Number CCR-9701973.
The content of the information does not necessarily reflect the position or the policy of the US Governmen
t and no official endorsement should be inferred.
We thank Dennis Heimbigner, Richard S. Hall, and André van der Hoek of the Software Engineering Research Laboratory,
University of Colorado at Boulder (circa 1997), and Giampaolo Cugola, Elisabetta Di Nitto, and Alfonso Fuggetta of
Politecnico di Milano for their contributions to this work.
this page is maintained by Antonio Carzaniga and was updated on September 15, 2019

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -17,8 +17,8 @@ import transport.TimeoutAction;
public class GBNTReceiver extends Receiver implements TimeoutAction { public class GBNTReceiver extends Receiver implements TimeoutAction {
private char sequence; private char sequence;
boolean firstPacket = true; private boolean firstPacket = true;
private static final int RECEIVER_TIMEOUT_MS = 5000; private static final int RECEIVER_TIMEOUT_MS = 15000;
private State state = State.SETUP; private State state = State.SETUP;
enum State { enum State {
@ -85,18 +85,18 @@ public class GBNTReceiver extends Receiver implements TimeoutAction {
} }
if (length < 3) return; if (length < 3) return;
char seq = readBigEndianChar(bytes, offset); char seq = readBigEndianChar(bytes, offset);
System.out.print("Read sequence: " + (int) seq + " -> "); System.out.print("Read sequence: " + (int) seq + " Exp: " + (int) incrementAndRollover(sequence)+ " -> ");
if (seq != incrementAndRollover(sequence)) { if (seq == incrementAndRollover(sequence)) {
System.out.println("Dropping");
return;
} //drop the packet
else {
this.deliver(bytes, offset + 2, length - 2); this.deliver(bytes, offset + 2, length - 2);
sequence = incrementAndRollover(sequence); sequence = incrementAndRollover(sequence);
System.out.print("OK! ");
} else {
System.out.print("Drop ");
}
System.out.println("Sending ack: "+ (int) sequence); System.out.println("Sending ack: "+ (int) sequence);
this.unreliableSend(generateACK(sequence), 0, 2); this.unreliableSend(generateACK(sequence), 0, 2);
}
break; break;
} }
} }

View file

@ -48,11 +48,12 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
this.length = Math.min(length, MAX_PACKET_SIZE - 2); this.length = Math.min(length, MAX_PACKET_SIZE - 2);
contents = new byte[this.length + 2]; contents = new byte[this.length + 2];
writeBigEndianChar(contents, sequence); writeBigEndianChar(contents, sequence);
System.arraycopy(buffer, offset + 2 - 2, contents, 2, contents.length - 2); System.arraycopy(buffer, offset, contents, 2, contents.length - 2);
packetMap.put(this.sequence, this); packetMap.put(this.sequence, this);
} }
void send() { void send() {
System.out.println("Sending seq: " + (int) sequence + " - (" + length + " + 2 bytes)");
estimateStart = System.currentTimeMillis(); estimateStart = System.currentTimeMillis();
unreliableSend(contents, 0, contents.length); unreliableSend(contents, 0, contents.length);
} }
@ -72,13 +73,23 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
char getSequence() { return sequence; } char getSequence() { return sequence; }
} }
private static final char W = 10; /**
* Change this parameter to change the window size
*/
private static final char W = 16;
private char base = (char) (new Random().nextInt() % 65536); private char base = (char) (new Random().nextInt() % 65536);
private char waitingACK = 0; private char waitingACK = 0;
private int timeoutMs = 500; private int timeoutMs = 500;
private double rttEWMA = 100; private double rttEWMA = 100;
private double devRttEWMA = 100; private double devRttEWMA = 100;
private void resetTimeoutEstimation() {
timeoutMs = 500;
rttEWMA = 100;
devRttEWMA = 100;
}
private State state = State.SETUP; private State state = State.SETUP;
private final Queue<Packet> packets = new ArrayDeque<>(); private final Queue<Packet> packets = new ArrayDeque<>();
@ -92,7 +103,7 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
devRttEWMA = 0.75 * devRttEWMA + 0.25 * (rttEWMA - rttMIllis); devRttEWMA = 0.75 * devRttEWMA + 0.25 * (rttEWMA - rttMIllis);
rttEWMA = 0.875 * rttEWMA + 0.125 * rttMIllis; rttEWMA = 0.875 * rttEWMA + 0.125 * rttMIllis;
timeoutMs = (int) (rttEWMA + 4 * devRttEWMA); timeoutMs = (int) (rttEWMA + 4 * devRttEWMA);
//System.out.println("devRTT: " + devRttEWMA + " RTT: " + rttEWMA + " timeout: " + timeoutMs); System.out.println("devRTT: " + devRttEWMA + " RTT: " + rttEWMA + " timeout: " + timeoutMs);
} }
private void flushAckedPackets() { private void flushAckedPackets() {
@ -106,6 +117,7 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
private byte[] createSetupPacket() { private byte[] createSetupPacket() {
byte[] packet = new byte[2]; byte[] packet = new byte[2];
System.out.println("Sending setup: " + (int) base);
writeBigEndianChar(packet, base); writeBigEndianChar(packet, base);
return packet; return packet;
} }
@ -116,6 +128,17 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
private void sendSetup() { private void sendSetup() {
unreliableSend(createSetupPacket(), 0, 2); unreliableSend(createSetupPacket(), 0, 2);
blockSender(); blockSender();
resetTimeout();
}
private boolean timeoutSet = false;
private void resetTimeout() {
if (timeoutSet) cancelTimeout(this);
if (waitingACK > 0 || state == State.SETUP) {
this.setTimeout(timeoutMs, this);
timeoutSet = true;
}
} }
@Override @Override
@ -128,9 +151,9 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
Packet p = new Packet(addAndRollover(base, waitingACK), bytes, offset, length); Packet p = new Packet(addAndRollover(base, waitingACK), bytes, offset, length);
waitingACK++; waitingACK++;
packets.add(p); packets.add(p);
System.out.println("Sending seq: " + (int) p.sequence + " - (" + p.length + " + 2 bytes)");
p.send(); p.send();
setTimeout(timeoutMs, this); resetTimeout();
if (waitingACK >= W) { if (waitingACK >= W) {
System.out.println("Window full " + (int) p.sequence); System.out.println("Window full " + (int) p.sequence);
@ -156,14 +179,28 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
} }
} }
private volatile boolean abortTimeout = false;
@Override @Override
public void timeoutAction() { public void timeoutAction() {
if (state == State.SENDING) abortTimeout = true;
timeoutActionImpl();
}
private synchronized void timeoutActionImpl() {
abortTimeout = false;
timeoutSet = false;
if (state != State.SETUP) {
for (Packet p : packets) { for (Packet p : packets) {
p.send(); p.send();
if (abortTimeout) {
break;
} }
else if (state == State.SETUP) }
sendSetup(); }
else sendSetup();
resetTimeoutEstimation();
resetTimeout();
} }
@Override @Override
@ -186,14 +223,14 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
char ackSeq = readBigEndianChar(bytes, offset); char ackSeq = readBigEndianChar(bytes, offset);
System.out.println("Received ACK: " + (int) ackSeq); System.out.println("Received ACK: " + (int) ackSeq);
cancelTimeout(this);
Packet p = packetMap.get(ackSeq); Packet p = packetMap.get(ackSeq);
if (p != null) computeTimeoutLength(p.getRTT()); if (p != null) computeTimeoutLength(p.getRTT());
boolean mustResume = waitingACK == W && state == State.SENDING; boolean mustResume = waitingACK < W && state == State.SENDING;
waitingACK -= (ackSeq + 1 - base); waitingACK -= (ackSeq + 1 - base);
base = incrementAndRollover(ackSeq); base = incrementAndRollover(ackSeq);
resetTimeout();
flushAckedPackets(); flushAckedPackets();
if (mustResume || (waitingACK == 0 && state == State.CLOSING)) { if (mustResume || (waitingACK == 0 && state == State.CLOSING)) {