Skip to content

Commit

Permalink
Add more retry times to wait for the solution in SegmentFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
zjkmxy committed Apr 15, 2024
1 parent fa6597d commit b25431a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ucla-irl/ndnts-aux",
"version": "2.0.2",
"version": "2.0.3",
"description": "NDNts Auxiliary Package for Web and Deno",
"scripts": {
"test": "deno test --no-check",
Expand Down
12 changes: 10 additions & 2 deletions src/sync-agent/deliveries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,20 @@ export class AtLeastOnceDelivery extends SyncDelivery {
const continuation = fetchSegments(prefix, {
segmentNumConvention: SequenceNum,
segmentRange: [update.loSeqNum, update.hiSeqNum + 1],
retxLimit: 80,
retxLimit: 600,
lifetimeAfterRto: 1000, // Lifetime = RTO + 1000
// The true timeout timer is the RTO, specified below
rtte: {
initRto: 50,
minRto: 50, // Minimal RTO is 50ms
// Minimal RTO is 50ms
// Note: This has to be small enough to quickly trigger the path switch of BestRoute strategy
// However, due to an implementation flaw of SegmentFetcher, RTO only doubles once per window.
// Thus, maxRTO does not make any sense most of the time: the RTT in Workspace can only be very small
// (when Interest is forwarded to right path) or very large (when wrong path or Data missing).
// Therefore, before the SegmentFetcher issue can get resolved, we use the retxLimit to control the
// maximum timeout: retxLimit = Expected Timeout / (2 * minRto)
// Default expected timeout is 1 min, thus retxLimit == 600
minRto: 50,
maxRto: 2000,
},
ca: new LimitedCwnd(new TcpCubic(), 10),
Expand Down
11 changes: 10 additions & 1 deletion src/sync-agent/sync-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ export class SyncAgent implements AsyncDisposable {
return this._ready;
}

/**
* Set the readiness to start or stop processing updates.
* Condition: Sync deliveries are only running when ready is true.
*/
public set ready(value: boolean) {
if (this._ready && !value) {
throw new Error(
'Due to implementation limit SVS is unstoppable. Please do not set ready = false manually for now.',
);
}
this._ready = value;
if (value) {
this.atLeastOnce.start();
Expand Down Expand Up @@ -201,7 +210,7 @@ export class SyncAgent implements AsyncDisposable {
verifier: this.verifier,
modifyInterest: { mustBeFresh: true },
lifetimeAfterRto: 2000,
retxLimit: 25,
retxLimit: 150, // See Deliveries. 60*1000/(2*200)=150. Default minRto = 150.
});
for await (const segment of result) {
// Cache packets
Expand Down
7 changes: 2 additions & 5 deletions src/workspace/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ export class Workspace implements AsyncDisposable {
}

public async destroy() {
this.syncAgent.ready = false;
await Promise.all([
this.yjsSnapshotMgr.destroy(),
this.syncAgent.destroy(),
]);
await this.syncAgent.destroy();
await this.yjsSnapshotMgr.destroy();
// persistStore is not created by workspace
}

Expand Down

0 comments on commit b25431a

Please sign in to comment.