diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index b4deeb5bc0..c46d7f41fb 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -55,7 +55,8 @@ struct TCP_SOCKET IP_SOCKET RemotePort dw ? t_state dd ? ; TCB state - t_rxtshift dd ? + t_rxtshift db ? + rb 3 ; align t_rxtcur dd ? t_dupacks dd ? t_maxseg dd ? @@ -125,10 +126,10 @@ struct TCP_SOCKET IP_SOCKET ;------- ; Timers - timer_retransmission dw ? ; rexmt - timer_persist dw ? - timer_keepalive dw ? ; keepalive/syn timeout - timer_timed_wait dw ? ; also used as 2msl timer + timer_retransmission dd ? ; rexmt + timer_persist dd ? + timer_keepalive dd ? ; keepalive/syn timeout + timer_timed_wait dd ? ; also used as 2msl timer ; extra diff --git a/kernel/branches/net/network/tcp_input.inc b/kernel/branches/net/network/tcp_input.inc index 0a37da541d..585e1803c3 100644 --- a/kernel/branches/net/network/tcp_input.inc +++ b/kernel/branches/net/network/tcp_input.inc @@ -198,7 +198,7 @@ TCP_input: ;-------------------- ; Process TCP options - push ecx + push ecx movzx ecx, [edx + TCP_header.DataOffset] cmp ecx, sizeof.TCP_header ; Does header contain any options? @@ -943,7 +943,7 @@ TCP_input: jne .no_restart mov eax, [ebx + TCP_SOCKET.t_rxtcur] - mov [ebx + TCP_SOCKET.timer_retransmission], ax + mov [ebx + TCP_SOCKET.timer_retransmission], eax .no_restart: diff --git a/kernel/branches/net/network/tcp_output.inc b/kernel/branches/net/network/tcp_output.inc index f01e330595..50d969f7f7 100644 --- a/kernel/branches/net/network/tcp_output.inc +++ b/kernel/branches/net/network/tcp_output.inc @@ -277,7 +277,7 @@ TCP_output: DEBUGF 1,"TCP_output: Entering persist state\n" mov [eax + TCP_SOCKET.t_rxtshift], 0 - TCP_set_persist eax + call TCP_set_persist @@: ;---------------------------- @@ -523,7 +523,7 @@ TCP_send: je .retransmit_set mov edx, [eax + TCP_SOCKET.t_rxtcur] - mov [eax + TCP_SOCKET.timer_retransmission], dx + mov [eax + TCP_SOCKET.timer_retransmission], edx cmp [eax + TCP_SOCKET.timer_persist], 0 jne .retransmit_set diff --git a/kernel/branches/net/network/tcp_subr.inc b/kernel/branches/net/network/tcp_subr.inc index eb0bada8b2..46cae23758 100644 --- a/kernel/branches/net/network/tcp_subr.inc +++ b/kernel/branches/net/network/tcp_subr.inc @@ -16,6 +16,11 @@ $Revision$ +align 4 +iglobal + TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6 +endg + macro TCP_checksum IP1, IP2 { ;------------- @@ -467,36 +472,63 @@ TCP_respond_segment: ret +macro TCPT_RANGESET timer, value, min, max { -macro TCP_set_persist socket { +local .min +local .max +local .done + + cmp value, min + jb .min + cmp value, max + ja .max + + mov timer, value + jmp .done + + .min: + mov timer, value + jmp .done + + .max: + mov timer, value + jmp .done + + .done: +} + + +align 4 +TCP_set_persist: ; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive -; cmp [socket + TCP_socket.timer_retransmission] + cmp [eax + TCP_SOCKET.timer_retransmission], 0 + jg @f ; calculate RTO -; mov ecx, [socket + TCP_socket.t_srtt] -; shr ecx, 2 -; add ecx, [socket + TCP_socket.t_rttvar] -; shr ecx, 1 + push ebx + mov ebx, [eax + TCP_SOCKET.t_srtt] + shr ebx, 2 + add ebx, [eax + TCP_SOCKET.t_rttvar] + shr ebx, 1 -; and [socket + TCP_socket.t_flags], not TF_PREVVALID - -;if (tcp_timer_active(tp, TT_REXMT)) -; panic("tcp_setpersist: retransmit pending"); + mov cl, [eax + TCP_SOCKET.t_rxtshift] + shl ebx, cl ; Start/restart persistance timer. -;TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], TCPTV_PERSMIN, TCPTV_PERSMAX); -;tcp_timer_activate(tp, TT_PERSIST, tt); + TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max -; cmp [socket + TCP_socket.t_rxtshift], TCP_MAXRXTSHIFT -; jae @f -; inc [socket + TCP_socket.t_rxtshift] -; @@: + pop ebx -} + cmp [eax + TCP_SOCKET.t_rxtshift], TCP_max_rxtshift + jae @f + inc [eax + TCP_SOCKET.t_rxtshift] + @@: + + ret diff --git a/kernel/branches/net/network/tcp_timer.inc b/kernel/branches/net/network/tcp_timer.inc index 01f11b355b..1e8b46e7bc 100644 --- a/kernel/branches/net/network/tcp_timer.inc +++ b/kernel/branches/net/network/tcp_timer.inc @@ -116,6 +116,13 @@ local .exit DEBUGF 1,"socket %x: persist timer expired\n", eax + call TCP_set_persist + mov [eax + TCP_SOCKET.t_force], 1 + push eax + call TCP_output + pop eax + mov [eax + TCP_SOCKET.t_force], 0 + jmp .loop .exit: