Forum: PC-Programmierung TCP Keep-Alive -- SEQ/WND verwirrung


von Daniel A. (daniel-a)


Lesenswert?

TCP Keep-Alives lasen mich gerade an meinem TCP-Verständniss zweifeln.

Folgende Situation:

Gemäss:
http://tools.ietf.org/html/rfc793#page-20
gibt es einen "Receive Sequence Space"
Zitat:
1
                       1          2          3
2
                   ----------|----------|----------
3
                          RCV.NXT    RCV.NXT
4
                                    +RCV.WND
5
6
        1 - old sequence numbers which have been acknowledged
7
        2 - sequence numbers allowed for new reception
8
        3 - future sequence numbers which are not yet allowed

Ich habe eine Situation die folgender sehr ähnelt, aber in einem Punkt 
abweicht:
http://tools.ietf.org/html/rfc793#page-31

Situation:
1
  1.  CLOSED                                               LISTEN
2
3
  2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
4
5
  3.  ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
6
7
  4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
8
9
  5.  ESTABLISHED --> <SEQ=100><ACK=301><CTL=ACK> --> ESTABLISHED    <-- TCP Keep Alive, hier ist mein Verständnisproblem.

Ich verbinde mich mit meinem Programm mit Telnet auf Port 80. Dabei geht 
alles bis zum schritt 4. Aber wenn ich etwas eingebe und versende, 
bekommt mein Programm von Telnet nicht die Daten: 
"<SEQ=101><ACK=301><CTL=ACK><DATA>", sondern ein TCP Keep-Alive: 
"<SEQ=100><ACK=301><CTL=ACK>".

Mein Problem damit: die Sequenznumer 100 liegt nichtmehr in meinem 
recive window, da zu diesem Zeitpunkt SEG.SEQ=100 kleiner als RCV.NXT 
ist:
http://tools.ietf.org/html/rfc793#page-25
1
 A segment is judged to occupy a portion of valid receive sequence
2
  space if
3
4
    RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
5
6
  or
7
8
    RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND

Ich habe das komische gefühl, als ob ich irgendetwas offensichtliches 
übersehe, aber ich komme einfach nicht dahinter... Wiso ist dieses TCP 
Keep-Alive erlaubt, und warum wird es hier gesendet?

von Jope (Gast)


Lesenswert?

RFC 1122, Seite 102:
1
"Some TCP implementations, however, have included a
2
keep-alive mechanism.  To confirm that an idle
3
connection is still active, these implementations send
4
a probe segment designed to elicit a response from the
5
peer TCP.  Such a segment generally contains SEG.SEQ =
6
SND.NXT-1 and may or may not contain one garbage octet
7
of data.  Note that on a quiet connection SND.NXT =
8
RCV.NXT, so that this SEG.SEQ will be outside the
9
window.  Therefore, the probe causes the receiver to
10
return an acknowledgment segment, confirming that the
11
connection is still live.  If the peer has dropped the
12
connection due to a network partition or a crash, it
13
will respond with a RST instead of an acknowledgment
14
segment."

von Daniel A. (daniel-a)


Lesenswert?

Danke! Das erklärt alles.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.