Tcp echo app
This presentation is the property of its rightful owner.
Sponsored Links
1 / 5

TCP_ECHO_APP 분석 PowerPoint PPT Presentation


  • 40 Views
  • Uploaded on
  • Presentation posted in: General

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.

Download Presentation

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Tcp echo app

TCP_ECHO_APP 분석

JSYOON

2010. 1. 6


Buffer for send recv in tcp

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


Example

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


Recvn

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);

  • }


Modified recvn

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


  • Login