-
Notifications
You must be signed in to change notification settings - Fork 82
/
tcpack.hh
80 lines (68 loc) · 2.46 KB
/
tcpack.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef CLICK_TCPACK_HH
#define CLICK_TCPACK_HH
#include <click/element.hh>
#include <click/timer.hh>
#include <clicknet/tcp.h>
CLICK_DECLS
/*
* =c
* TCPAck([ACK_DELAY])
* =s tcp
* acknowledge TCP packets
* =d
*
* performs TCP style acknowledgement. marked TCP/IP packets are expected on
* both input and output ports. use MarkIPHeader to mark packets.
*
* input port 0 is TCP input. a packet that arrives on this input may trigger
* an acknowledgement. the acknowledgement acknowledges the latest in-order
* packet received. TCPAck gets this information from a downstream TCPBuffer
* element that it discovers using flow-based router context, much like how
* RED elements discover their QUEUE elements. the packet is sent out on
* output port 0 untouched.
*
* input port 1 is TCP output. a packet that arrives on this input get tagged
* with an acknowledgement number. this ack number is obtained from TCPBuffer
* as described above. this packet also causes TCPAck to cancel scheduled ACK.
* the packet is then sent out on output port 1.
*
* finally, output port 2 is used to send scheduled ACKs. packets generated on
* this port does not have any of the flow ID nor sequence number. another
* element, such as TCPConn, should be used downstream from this port to set
* those fields. an ACK is generated on this output only if after ACK_DELAY
* number of ms a triggered acknowledge was not sent. by default, ACK_DELAY is
* set to 20.
*
* TCPAck only deals with DATA packets. it doesn't try to acknowledge SYN and
* FIN packets. TCPAck starts using ack number from the first SYN ACK packet
* it sees on in/output port 0 or 1. packets before that are rejected.
*
* TCPAck does not compute checksum on any packets. use SetIPChecksum and
* SetTCPChecksum instead.
*/
class TCPBuffer;
class TCPAck : public Element {
private:
Timer _timer;
bool _synack;
bool _needack;
unsigned _ack_nxt;
TCPBuffer *_tcpbuffer;
unsigned _ackdelay_ms;
bool iput(Packet *);
bool oput(Packet *);
void send_ack();
public:
TCPAck() CLICK_COLD;
~TCPAck() CLICK_COLD;
const char *class_name() const override { return "TCPAck"; }
const char *port_count() const override { return "2/3"; }
const char *processing() const override { return "aa/aah"; }
int initialize(ErrorHandler *) CLICK_COLD;
int configure(Vector<String> &conf, ErrorHandler *errh) CLICK_COLD;
void push(int, Packet *);
Packet *pull(int);
void run_timer(Timer *);
};
CLICK_ENDDECLS
#endif