1 / 10

참고문헌 : Etcp Unp My Program

Enhancing Your Network Programming Skill - Part 2 Programming Tips for helping your ARQ design Project. 참고문헌 : Etcp Unp My Program. Making Your Apps Event Driven. Types of events in protocols and networked application Packet arrival User input Timeout API call

almira
Download Presentation

참고문헌 : Etcp Unp My Program

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. Enhancing YourNetwork Programming Skill- Part 2Programming Tips for helping your ARQ design Project 참고문헌: Etcp Unp My Program

  2. Making Your Apps Event Driven • Types of events in protocols and networked application • Packet arrival • User input • Timeout • API call • 만일, API도 UNIX domain socket(일종의 socket descriptor임)이라면 select()로 API call이 발생했음을 확인 가능 • 다만, select()는 timeout은 하나만 가능 • How to support multiple timeouts using select() ? • You can make it ! select()로 확인 가능 (Ready or timeout? )

  3. Timers in UNIX/Linux • Using SIGALRM signal: 초 단위 • Interval timer: 실제는 10 msec 단위로 작동 • select(): 실제 10 msec 단위로 작동 signal(SIGALRM, handler); // or sigaction(…) … alarm(seconds); // set timeout timer … void handler(in signo) { …. }; // actions in timeout event #include <sys/time.h> intgetitimer(ITIMER_REAL, structitimerval *value); intsetitimer(int which, const structitimerval *value, structitimerval *ovalue); structitimerval { structtimevalit_interval; /* next value */ structtimevalit_value; /* current value */ }; structtimeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */

  4. Multiple Timeouts using select() #include “etcp.h” int tselect( int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset ); Returns: # of ready events, 0 if no remaining events, -1 on error unsigned int timeout( void (*handler)(void *), void *arg, int msec ); Returns: timer ID to be used in untimeout call void untimeout( unsigned int timerid ); Examples /* call retransmit(packet) after 1500 msec (timeout) */ rxtimer = timeout(retransmit, (void *) packet, 1500 ); UItimer = timeout(useridle, NULL, 30000); … n = tselectmaxfdp1, &readset, &writeset, &exceptset ); … // if received ACK, untimeout(rxtimer); // reset the timer

  5. Tselect() source from ‘etcp’ lib/tselect.c

  6. Internet Checksum Algorithm

  7. How to simulate packet error & lost

More Related