참고문헌 : etcp unp my program
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
Enhancing YourEnhancing YourNetwork Programming SkillNetwork Programming Skill- Part 2- Part 2
Programming Tips for helping your ARQ Programming Tips for helping your ARQ design Projectdesign Project
참고문헌 : Etcp
Unp
My Program
Making Your Apps Event DrivenMaking 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? )
Timers in UNIX/LinuxTimers 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>int getitimer(ITIMER_REAL, struct itimerval *value);int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue); struct itimerval { struct timeval it_interval; /* next value */ struct timeval it_value; /* current value */ }; struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */
Multiple Timeouts using select()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 errorunsigned int timeout( void (*handler)(void *), void *arg, int msec ); Returns: timer ID to be used in untimeout callvoid untimeout( unsigned int timerid );
/* 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
Examples
Tselect() source from ‘etcp’ Tselect() source from ‘etcp’
lib/tselect.c
Internet Checksum AlgorithmInternet Checksum Algorithm
How to simulate packet error & lostHow to simulate packet error & lost