1 / 5

TCP_ECHO_APP 분석

TCP_ECHO_APP 분석. JSYOON 2010. 1. 6. Buffer for send/ recv in TCP. Packets are not discrete data in TCP. They are flow !. recv ( socket, app_buff , sizeof ( app_buff ), flags ) returns recv_length. Server side. Flow Control by TCP. Client side. APP. Recv_Buffer. Send_Buffer.

gay-vang
Télécharger la présentation

TCP_ECHO_APP 분석

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TCP_ECHO_APP 분석 JSYOON 2010. 1. 6

  2. Buffer for send/recv in TCP • Packets are not discrete data in TCP.They are flow ! recv ( socket, app_buff, sizeof(app_buff), flags) returns recv_length Server side Flow Control by TCP Client side APP Recv_Buffer Send_Buffer APP Send_Buffer Recv_Buffer send ( socket, app_buff, sizeof(app_buff), flags) returns send_length

  3. Example • APP_Buff size: 5 send ( socket, app_buff, sizeof(app_buff), flags) returns send_length Server side Flow Control by TCP Client side abcde APP Recv_Buffer Send_Buffer APP APP_Buff APP_Buff Send_Buffer Recv_Buffer recv ( socket, app_buff, sizeof(app_buff), flags) returns recv_length

  4. recvn( ) • recvn(socket ID, stored buffer, buffer size, flags) • Loop until (left buffer size > 0) • take amount of left buffer size from TCP_RECV_BUFFERthen return recv_size • if recv_size is zero, it doesn’t do anything • left buffer size is reduced by recv_size • pointer has to increase as recv_size • int • recvn(SOCKET s, char *buf, int len, int flags) • { • int received; • char *ptr = buf; • int left = len; • while (left > 0) • { • received = recv(s, ptr, left, flags); • if (received == SOCKET_ERROR) • { • return SOCKET_ERROR; • } • else if (received == 0) • { • break; • } • left -= received; • ptr += received; • } • return (len - left); • }

  5. Modified recvn( ) • while (1) • {r_len=recv(sock, r_buf, BUFSIZE, 0); • if (r_len==0 || r_len==s_len) • { • break; • } • } • Do Loop • Take data from TCP_RECV_BUFFER as much as sizeof(r_buf) • If recv_data size is zero or recv_data is the same as sent data size, then the loop is finished

More Related