Original text(via Lobsters)

Trickles: A Stateless Network Stack for Improved Scalability, Resilience, and Flexibility
Alan Shieh Andrew C. Myers Emin G�n Sirer Dept. of Computer Science Cornell University Ithaca, NY 14853 {ashieh,andru,egs}@cs.cornell.edu
Abstract: Traditional operating system interfaces and network protocol implementations force system state to be kept on both sides of a connection. Such state ties the connection to an endpoint, impedes transparent failover, permits denial-of-service attacks, and limits scalability. This paper introduces a novel TCP-like transport protocol and a new interface to replace sockets that together enable all state to be kept on one endpoint, allowing the other endpoint, typically the server, to operate without any per-connection state. Called Trickles, this approach enables servers to scale well with increasing numbers of clients, consume fewer resources, and better resist denial-of-service attacks. Measurements on a full implementation in Linux indicate that Trickles achieves performance comparable to TCP/IP, interacts well with other flows, and scales well. Trickles also enables qualitatively different kinds of networked services. Services can be geographically replicated and contacted through an anycast primitive for improved availability and performance. Widely-deployed practices that currently have client-observable side effects, such as periodic server reboots, connection redirection, and failover, can be made transparent, and perform well, under Trickles. The protocol is secure against tampering and replay attacks, and the client interface is backwards-compatible, requiring no changes to sockets-based client applications.
1 Introduction
Figure 1: TCP versus Trickles state. (A) TCP holds state at server, even for idle connection x.x.x.2. (B) Trickles encapsulates and ships server state to the client.

2 Stateless Transport Protocol
2.1 Transport and user continuations
2.2 Security
Maintaining state integrity
Protection against replay
2.3 The trickle abstraction
Figure 2: A sample TCP or Trickles connection. Each line pattern corresponds to a different trickle. Initially, there are cwnd trickles. At points where cwnd increases (A, B), trickles are split.

2.4 Trickle dataflow constraints
Figure 3: Difference in state/result availability between TCP and Trickles. TCP server knows the result of processing (A) earlier than Trickles server.

Figure 4: Equivalence of reverse and forward path loss in Trickles. Due to dataflow constraints, the packet following a lost packet does not compensate for the loss immediately. Neither the server nor the client can distinguish between (A) and (B). The loss will be discovered through subsequent SACK proofs.

2.5 Congestion control algorithm
Slow start and congestion avoidance
- CwndDelta := TCPCwnd(k) - TCPCwnd(k - 1)
- Generate CwndDelta + 1 responses: continue the original trickle, and split CwndDelta times.
Figure 5: Closed-form solution of TCP simulation.

Fast retransmit/recovery
Figure 6: TCP recovery. Duplicate ACKs signal recovery (A). Subsequent ACKs are ignored until number of outstanding packets drops to new cwnd. Recovery ends when client acknowledges all packets (B). Figure 7: Trickles Recovery. First packet following loss triggers a retransmission (A). Trickles are subsequently terminated to deflate cwnd (B). Recovery ends when cwnd survivors are generated; cwnd has dropped from the original value of 5 to 2 (C).


- firstLoss := sequence number of first loss in input cwndAtLoss := TCPCwnd(firstLoss - 1) lossOffset := k - firstLoss newCwnd := numInFlight / 2 The protocol variable firstLoss is derived from the SACK proof. The SACK proofs for the trickle immediately after a loss, as well as all subsequent trickles before recovery, will report a gap. The SACK prefix invariant ensures that each trickle will compute consistent values for the protocol variables shown above.
firstLoss := sequence number of
first loss in input
cwndAtLoss := TCPCwnd(firstLoss - 1)
lossOffset := k - firstLoss
newCwnd := numInFlight / 2
- If k acknowledges the first packet after a run of losses, retransmit the lost packets (Figure 7). This is required to achieve the reliable delivery guarantees of TCP. A burstLimit parameter, similar to that suggested for TCP [1], limits the number of packets that may be retransmitted in this manner; losses beyond burstLimit are handled via a timeout and not via fast retransmit.
- The goal in fast retransmit is to terminate n = cwndAtLoss - newCwnd trickles, and generate newCwnd survivor trickles. We choose to terminate the first n trickles, and retain the last newCwnd trickles using the following algorithm: (a) If cwndAtLoss - lossOffset < newCwnd, continue the trickle. Otherwise, terminate the trickle. (b) If k immediately follows a run of losses, generate the trickles for all missing requests that would have satisfied (a). Test (a) deflates the number of trickles to newCwnd. First, a sufficient number of trickles are terminated to drop the number of trickles to newCwnd. Then, all subsequent trickles become survivors that will bootstrap the subsequent slow start/congestion avoidance phase. If losses occur while sending the surviving trickles to the client, then the number of outstanding trickles will fall below newCwnd. So condition (a) guarantees that the new window size will not exceed the new target, while condition (b) ensures that the new window will meet the target. Note that when the server decides to recreate multiple lost trickles per condition (b), it will not have access to corresponding user continuations for the lost packets. Consequently, the server transport layer cannot invoke the application and generate the corresponding data payload. Instead, the server transport layer simply generates the transport continuations associated with the lost trickles and ships them to the client as a group. The client then regenerates the trickles by retransmitting these requests to the server with matching user continuations.
Retransmit timeout
- a := firstLoss ssthresh := TCPCwnd(a-1)/2 cwnd := InitialCwnd
- Split cwnd - 1 times to generate cwnd survivors. Set TCPCwnd(k) initial conditions to equivalent TCP post-recovery state.
2.6 Compatibility with TCP
3 Trickles server API
3.1 The event queue
3.2 Minisockets
3.3 Minisocket operations
msk_send(int fd, minisock , char , size_t); msk_sendv(int fd, minisock , tiovec , int); msk_sendfilev(int fd, minisock , fiovec , int); msk_setucont(int fd, minisock , int pkt, char buf, size_t); msk_sendbulk(int fd, mskdesc , int len); msk_drop(int fd, minisock ); msk_detach(int fd, minisock ); msk_extract_events(int fd, extract_mskdesc_in , int inlen, msk_collection , int outlen); msk_install_events(int fd, msk_collection , int); msk_request(int fd, char req, int reqlen, int reservelen); Figure 8: The minisocket API.
msk_send(int fd, minisock *, char *, size_t);
msk_sendv(int fd, minisock *, tiovec *, int);
msk_sendfilev(int fd, minisock *, fiovec *, int);
msk_setucont(int fd, minisock *, int pkt,
char* buf, size_t);
msk_sendbulk(int fd, mskdesc *, int len);
msk_drop(int fd, minisock *);
msk_detach(int fd, minisock *);
msk_extract_events(int fd, extract_mskdesc_in *,
int inlen, msk_collection *, int *outlen);
msk_install_events(int fd, msk_collection *, int);
msk_request(int fd, char *req, int reqlen,
int reservelen);
4 Client-side processing
4.1 Standardized user continuations
4.2 Input continuations
4.3 Output continuations
5 Optimizations
5.1 Socket caching
5.2 Parallel requests and sparse sequence numbers
5.3 Delta encoding
Figure 9: Aggregate throughput for Trickles and TCP. TCP fails for tests with more than 6000 clients.

6 Evaluation
6.1 Microbenchmarks
Throughput
Figure 10: Trickles and TCP throughput for a single, isolated client at various object sizes.

Memory and CPU utilization
Figure 11: Memory utilization. Includes socket structures, socket buffers, and shared event queue.

Figure 12: Server-side CPU overhead on a 1 Gb/s link.

Figure 13: Interaction of Trickles and TCP.

Interaction with TCP flows
Continuation optimizations
Figure 14: Throughput comparison of pipelined transfers with 20 kB objects, smaller than the bandwidth-delay product.

Summary
6.2 Macrobenchmarks
PlanetLab measurements
Figure 15: Trickles and TCP PlanetLab throughput.

Instantaneous failover
Figure 16: Failover behavior. Disconnection occurs at t=10 seconds.

Packet-level load balancing
Figure 17: Jain's fairness index in load balancing cluster with two servers and two clients. Allocation is fair when each client receives the same number of bytes.

Dynamic content
7 Related Work
8 Conclusions and future work
Acknowledgments
References
| This paper was originally published in the Proceedings of the 2nd Symposium on Networked Systems Design and Implementation, May 2–4, 2005, Boston, MA, USA Last changed: 2 May 2005 aw | NSDI '05 Technical Program NSDI '05 Home USENIX home | NSDI '05 Technical Program | NSDI '05 Home | USENIX home |
|---|---|---|---|---|
| NSDI '05 Technical Program | ||||
| NSDI '05 Home | ||||
| USENIX home |