Proper initialization for TCP socket (net branch)

git-svn-id: svn://kolibrios.org@2612 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-04-14 18:20:01 +00:00
parent d6ef0c989b
commit 6b6bbac3ce
5 changed files with 111 additions and 108 deletions

View File

@ -324,7 +324,7 @@ align 4
mov [eax + SOCKET.snd_proc], SOCKET_send_tcp
mov [eax + SOCKET.rcv_proc], SOCKET_receive_tcp
mov [eax + TCP_SOCKET.t_maxseg], 1480 ;;;;; FIXME
TCP_init_socket eax
ret
@ -498,11 +498,13 @@ align 4
mov [eax + TCP_SOCKET.timer_persist], 0
mov [eax + TCP_SOCKET.t_state], TCPS_SYN_SENT
push [TCP_sequence_num]
add [TCP_sequence_num], 6400
pop [eax + TCP_SOCKET.ISS]
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
TCP_sendseqinit eax
; mov [ebx + TCP_SOCKET.timer_retransmission], ;; todo: create macro to set retransmission timer

View File

@ -66,6 +66,7 @@ TCP_time_keep_init equ 118 ; connectione stablishment (75,52s)
TCP_time_keep_idle equ 4608 ; idle time before 1st probe (2h)
TCP_time_keep_interval equ 118 ; between probes when no response (75,52s)
TCP_time_rtt_default equ 5 ; default Round Trip Time (3,2s)
TCP_time_srtt_default equ 0 ;
; timer constants
TCP_max_rxtshift equ 12 ; max retransmissions waiting for ACK
@ -77,6 +78,8 @@ TCP_max_win equ 65535
TCP_re_xmit_thresh equ 3
TCP_mss_default equ 1480 ; default max segment size
struct TCP_header
SourcePort dw ?

View File

@ -595,6 +595,8 @@ align 4
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
;;; TODO: check if we should scale the connection (567-572)
mov [ebx + TCP_SOCKET.SND_SCALE], 0
;;; TODO: update RTT estimators
jmp .trim_then_step6
@ -1249,24 +1251,7 @@ align 4
.update_window:
DEBUGF 1,"Updating window\n"
; Keep track of pure window updates
; test ecx, ecx
; jz @f
;
; mov eax, [ebx + TCP_SOCKET.SND_WL2]
; cmp eax, [edx + TCP_header.AckNumber]
; jne @f
;
; ;; mov eax, tiwin
; cmp eax, [ebx + TCP_SOCKET.SND_WND]
; jbe @f
;
; ;;; update stats
;
; @@:
;;; TODO: Keep track of pure window updates
mov eax, dword [edx + TCP_header.Window]
cmp eax, [ebx + TCP_SOCKET.max_sndwnd]
@ -1275,6 +1260,8 @@ align 4
@@:
mov [ebx + TCP_SOCKET.SND_WND], eax
DEBUGF 1,"Updating window to %d\n", eax
push [edx + TCP_header.SequenceNumber]
pop [ebx + TCP_SOCKET.SND_WL1]

View File

@ -100,13 +100,14 @@ TCP_output:
@@:
sub esi, ebx
;------------------------
; check for window shrink (107)
; If FIN has been set, but not ACKed, but we havent been called to retransmit, esi will be -1
; Otherwise, window shrank after we sent into it.
jns .not_negative
jae .not_persist
; enter persist state
xor esi, esi
@ -126,7 +127,7 @@ TCP_output:
; If window didn't close completely, just wait for an ACK
.not_negative:
.not_persist:
;---------------------------
; Send one segment at a time (124)
@ -291,7 +292,7 @@ TCP_output:
.send:
DEBUGF 1,"Preparing to send a segment\n"
DEBUGF 1,"Preparing to send a segment socket: %x length: %u flags: %x\n", eax, esi, dl
mov edi, sizeof.TCP_header ; edi will contain headersize

View File

@ -82,11 +82,21 @@ macro TCP_rcvseqinit ptr {
macro TCP_init_socket socket {
mov [socket + TCP_SOCKET.t_maxseg], TCP_mss_default
mov [socket + TCP_SOCKET.t_flags], 0 ; we could also request scale and timestamp
mov [socket + TCP_SOCKET.t_srtt], TCP_time_srtt_default
mov [socket + TCP_SOCKET.t_rttvar], TCP_time_rtt_default * 4
mov [socket + TCP_SOCKET.t_rttmin], TCP_time_re_min
;;; TODO: TCP_time_rangeset
mov [socket + TCP_SOCKET.SND_CWND], TCP_max_win shl TCP_max_winshift
mov [socket + TCP_SOCKET.SND_SSTHRESH], TCP_max_win shl TCP_max_winshift
}
;---------------------------