100 likes | 182 Views
Project Goal. Convert existing (real) TCP/IP applications to native API This should be done with minimum modifications of the applications’ source code The basic idea is to give the applications the illusion of working with a normal TCP/IP library. Socket TCP/IP API.
E N D
Project Goal • Convert existing (real) TCP/IP applications to native API • This should be done with minimum modifications of the applications’ • source code • The basic idea is to give the applications the illusion of working with a • normal TCP/IP library
Socket TCP/IP API • int socket(int type,int family,int protocol); • int bind(int socket,const struct sockaddr* sa,int addrlen); • int listen(int socket,int backlog); • int accept(int socket,struct sockaddr* sa,int* addrlen); • int connect(int socket,const struct sockaddr* sa,int addrlen); • int read(int fd,void* buffer,int buff_size); • int write(int fd,const void* buffer,int buff_size); • int recv(int fd,void* buffer,int buff_size,int flags); • int send(int fd, const void* buffer,int buff_size,int flags); • int sendto(int fd, const void* buffer,int buff_size, • const struct sockaddr* sa,int addrlen,int size); • int recvfrom(int fd,void* buffer,int buff_size, • struct sockaddr* sa,int* addrlen,int flags); • int setsockopt (int socket, int level, int optname, const char* optval, int optlen); • int getsockopt (int socket, int level, int optname, char* optval, int optlen); • int close(int socket); • struct hostent* gethostbyname(const char* hostname); • struct hostent* gethostbyaddr(const char* hostaddr,int addrlen);
Fore ATM API • int atm_open(char* device,int flags,Atm_info* info); • int atm_bind(int fd,Atm_sap asap,Atm_sap* asap_assigned,int qlen); • int atm_listen(int fd,int*conn_id,Atm_endpoint* calling, • Atm_qos* qos,Aal_type* aal); • int atm_accept(int fd,int newfd,int conn_id,Atm_qos* qos,Atm_dataflow dataflow); • int atm_connect(int fd,Atm_endpoint* dest,Atm_qos* qos, • Atm_qos_sel* qos_sel,Aal_type aal,Atm_dataflow dataflow); • int atm_recv(int fd,caddr_t buffer,int buff_size); • int atm_send (int fd, caddr_t buffer,int buff_size); • int atm_close(int fd); • int atm_gethostbyname(char* hostname,Atm_address* dest_addr);
Similarities between Socket TCP/IP and Fore ATM APIs TCP/IP API Fore ATM API socket atm_open bind atm_bind listen atm_bind + atm_listen accept atm_listen + atm_accept connect atm_connect read, recv atm_recv write, send atm_send close atm_close gethostbyname atm_gethostbyname
Similarities between Socket TCP/IP and Fore ATM APIs (2) TCP/IP API Fore ATM API socket ATM file descriptor port ATM service access point IP address ATM address struct sockaddr Atm_endpoint
General Assumptions • the source code of the application is available • the source code for the standard C/C++ runtime library is not available • the source code for the TCP/IP network library is not available
local_address Address table File descriptor table IP ATM ref_cnt 2 fd name peer type buff qos SOCK_DGRAM 1 Endpoint table port nsap address ref_cnt 1 1 Data structures for connection-oriented (stream) sockets emulation
local_address Address table (Fictive) File descriptor table IP ATM ref_cnt 2 fd real_fd type name SOCK_DGRAM 1 Real File descriptor table (one for each fictive fd) Endpoint table fd peer port nsap address ref_cnt 1 1 Data structures for connectionless (datagram) sockets emulation
How should we modify the applications ? • The following line should be added as the first line in every source and header file: #include “atm_cheat.h” • The linker options should be set up to link the final code with the • libatm-cheat.a library • The ATM_HOST_NAME environment variable should be set at runtime to indicate • the name of the local host • This should be all :-). However some analysis of the source code of the original • application is still necessary (see the next slide: limitations)
Limitations and Further Development • The dup() and dup2() system calls are not supported. This is a serious limitation. Lots • of real applications do use these calls. • I think it is possible to support these calls; however this requires some effort and • also either access to the source code of the runtime C/C++ library or some rewriting • of several standard I/O functions