logging in or signing up PART-FOUR vadapally Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 147 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: June 16, 2011 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Slide 1: UNIT-4 TRANSPORT LAYER INTERFACE TLI (Transaction Layer Interface) is a form of IPC Provided with system V release 3.1. TLI provides communication between processes on the same system or on different systems. TLI was introduced with system V Release 3.0 in 1986. TLI provides interface to the transport layer of the OSI model and user process. TLI is a library functions, this library has linked externally by link editor. The functions in TLI are functions not system calls because TLI is a set of user-callable functions that hides the actual interface to the network system. There are two terms used in TLI. Transport end points Transport provider Transport endpoint:- The two processes that are communicating are called transport end points by TLI. Transport Provider:- It is a set of routines on the host computer that provide communication support for a user process. UNIX NETWORK PROGRAMMING UNIT-4 1Slide 2: TLI provides the interface between the user process and the transport provider. Transport endpoint addresses:- TLI imposes no restrictions on the structure of a transport address. This allows new protocols to be supported without requiring by kernel changes. TLI defines a generic structure that passes various data between the TLI functions and the user code. #include<tiuser.h> struct netbuf { unsigned int maxlen; unsigned int len; char *buf; }; These structures are always passed between the user and the TLI function by reference. This structure is similar to the sockaddr structure. UNIX NETWORK PROGRAMMING UNIT-4 2Slide 3: Elementary TLI functions:- TLI functions can be used for a connection oriented and connection less protocol. UNIX NETWORK PROGRAMMING UNIT-4 3 t_open () t_bind () t_alloc () t_listen () t_accept () t_rcv() t_snd() t_open () t_bind () t_alloc () t_connect() t_snd() t_rcv() Connection establishment Data (request) Data reply Connection oriented protocolSlide 4: UNIX NETWORK PROGRAMMING UNIT-4 4 t_open () t_bind () t_alloc () t_rcvudata () t_sndudata() t_open () t_bind () t_alloc () Data (request) Data reply Connection less protocol t_sndudata() t_rcvudata ()Slide 5: t_open():- To open the unix file that identifies the particular transport provider. It returns a file descriptor that is used by the other TLI functions. #include<tiuser.h> int t_open(char *pathname, int oflag, struct t_info *info); Where pathname depends on the details of the transport provider being used. Oflag argument specifies the flags, t_info is the structure. Struct t_info { long addr; /* max size of the transport protocol address */ long optional; /* max bytes of protocol specific options */ long tsdu; /* max size of transport service data unit*/ long etsdu; /* max size of expedited transport service data unit */ long connect; /* max amount of data on connection establishment*/ long discon; /* disconnected*/ long servtype; /* service type supported*/ }; Pathname can be /dev/tcp, /tcp/udp or /dev/ip. UNIX NETWORK PROGRAMMING UNIT-4 5Slide 6: Service type specifies the type of service and has three possibilites T_COTS connection oriented service, without orderly realease. T_COTS_ORD WITH ORDERLY REALEASE T_CLTS CONNECTION LESS SERVICE t_alloc():- It provides a dynamic allocation of TLI structures in which the sizes of all the buffers. i.e., the data is allocated at runtime for transport provider. Syntax:- #include<tiuser.h> char *t_alloc(int fd, int structtype, int fields); where fd is file descriptor and struct type specifies the type of data structure as struct type type of structure T_BIND struct t_bind T_CALL t_call T_DIS t_discon T_INFO t_info Fields argument specify space for one or nore netbuf structure. Fields are T_ALL, T_ADDR, T_OPT AND T_UDATA UNIX NETWORK PROGRAMMING UNIT-4 6Slide 7: t_free():- This function frees a structure that was previously allocated t_alloc. Syntax:- int t_free(char v*ptr, int struct type); t_free not only frees the memory that was allocated and also first checks any netbuf structures contained there in and releases the memory used by buffers. t_bind():- This function assigns an address to a transport endpoint. It specifies the local-addr and local-process elements of the association 5-tuple. Syntax:- int t_bind(int fd, struct t_bind *request, struct t_bind *return); Where fd specifies the transport end point and t_bind is a structure. Struct t_bind { struct netbuf addr; unsigned int qlen; }; UNIX NETWORK PROGRAMMING UNIT-4 7Slide 8: t_connect():- This function can be executed by client process in connection oriented service. The purpose of this function is to send request to the server process. Syntax:- int t_connect(int fd, struct t_call *sendcall, struct t_call *recvcall); Struct t_call { struct netbuf addr; struct netbuf opt; struct netbuf udata; /*user data*/ int sequence; /* applies only to t_listen() function*/ }; The send call structure specifies the information needed by the transport ptovider to establish the connection. The addr structure specifies the structure specifies the server address. The recvcall structure contains the information associated with the connection that is returned by transport provider to the caller. The caller can put NULL for this structure if the returns information regarding the connection is not desired. UNIX NETWORK PROGRAMMING UNIT-4 8Slide 9: t_listen():- This function can be used in connection oriented service server process to identify requests from clients. A connection oriented server waits for connection request t_listen function. Syntax:- int t_listen(int fd, struct t_call *call); It only waits but not accepts the connection. t_accept():- This function is executed by server process to establish connection between two different process i.e., server and client. Once the t_listen function indicates that a connection request has arrived. To accept the request the t_accept function is called. Syntax:- int t_accept(int fd, int connfd, struct t_call *call); Here fd argument specifies the transport end point where the connection request arrived. The connfd argument specifies the transport endpoint where the connection is to be established. UNIX NETWORK PROGRAMMING UNIT-4 9Slide 10: t_snd() and t_rcv():- These two functions send or receive either normal or expedited (out of band )data . The purpose of this function are perform I?O operation between client and server. Syntax:- int t_snd(int fd, char *buff, unsigned int nbytes, int flags); int t_rcv(int fd, char *buff, unsigned int nbytes, int *flags); t_close():- The purpose of this function is to close transport endpoint connection. Syntax:- int t_close(int fd); t_sndudata() and t_rcvudata():- These two functions are used for connection less protocols to send and receive datagrams. Syntax:- int t_sndudata(int fd, struct t_unitdata *unitdata); int t_rcvudata(int fd, struct t_unitdata *unitdata, int *flags); UNIX NETWORK PROGRAMMING UNIT-4 10Slide 11: Advanced TLI functions Nonblocking I/O:- The transport end point can be put into a nonblocking (no wait ) state. This state can be set, when the end point is created with t_open function with flag=O_NDELAY. When a transport end point is nonblocking, the following TLI function can return immediately. t_getinfo():- The purpose of this function is to retrieve information about transport provider. Syntax:- int t_getinfo(int fd, struct t_info *info); t_getstate():- this function returns the current state to the caller, integer value to the caller. Syntax:- int t_getstate(int fd); The states are T_DATAXFER data transfer T_INCON incoming pending for server T_IDLE bound, but idle T_INREL incoming orderly release T_OUTCON outgoing connection pending for client T_OUTREL, T_UNBIND UNIX NETWORK PROGRAMMING UNIT-4 11Slide 12: t_optmgmt():- This function enables the caller to fetch or set protocol dependent options. Syntax: #include<tiuser.h> int t_optmgmt(int fd, struct t_optmgmt *request, struct t_optmgmt *return); This function corresponds to the getsockopt and setsockopt socket calls. t_rcvconnect ():- This function allows a client to initiate a connection request asynchronously. Syntax:- int t_rcvconnect(int fd, struct t_call *recvcall); t_sync():- This function synchronizes the data structures maintained by the TLI library with the current state of the transport end point specified by fd. Syntax:- int t_sync(int fd); It also returns the current state of the endpoint as the value of the function. UNIX NETWORK PROGRAMMING UNIT-4 12Slide 13: t_ubind():- The purpose of this function is to unbind for transport provider i.e., when allocated name for bind function is free. Syntax:- int t_ubind(int fd); UNIX NETWORK PROGRAMMING UNIT-4 13Slide 14: STREAMS Streams implemented by system 5 release 3.0. streams provide a full-duplex connection between a user process and a device driver. UNIX NETWORK PROGRAMMING UNIT-4 14 USER PROCESS STREAMS SYSTEM CALL INTERFACE DEVICE DRIVERSlide 15: Stream converted into stream head to perform input and output operations. The following diagram shows the full duplex nature. The stream head performed operations into the buffer, that buff can be called as “Processing module”. The processing module implemented in between the stream head and device driver and provided multiplexing in streams by using communication protocol in TCP and IP. UNIX NETWORK PROGRAMMING UNIT-4 15 USER PROCESS Processing module DEVICE DRIVER USER PROCESS STREAM HEAD STREAM HEAD DEVICE DRIVERSlide 16: UNIX NETWORK PROGRAMMING UNIT-4 16 User process User process User process STREAM HEAD STREAM HEAD STREAM HEAD TCP MODULE IP MODULE ETHERNET DRIVER ETHERNET DRIVERSlide 17: FEATURE OF STREAMS Full-duplex connection Here device driver may be pseudo driver i.e., there is no requirement that if associate with hardware device. Process can add modules between the stream head and the device driver, any number of modules can ‘pushed’ on to a stream. (LIFO). i.e., each new module gets inserted just below the stream head. Streams provide a mice layered implementation of the networking system. The stream module that accepts data from multiple sources is called a multiplexor. In stream networking the device driver becomes the network interface( ethernet , device driver, token ring etc.,) and the processing modules between the stream head and device driver implement a communication protocol. Streams are accessed through the following standard system calls Open(), close(), read(), write(), ioctl (), putmsg (), getmsg () and poll(). The data transferred up and down a stream consists of messages, each message contains a two parts.1. control and 2. data part. UNIX NETWORK PROGRAMMING UNIT-4 17Slide 18: These messages can be read or write through getmsg(), putmsg() system calls. getmsg():- The purpose of this message is to retrieve message from processing module. Syntax:- #include<stropts.h> int getmsg(int fd, struct strbuf *cntlptr, struct strbuf *dataptr, int *flags); put msg():- To store message into processing module. This function contain data part and control part. Syntax:- #include<stropts.h> int putmsg(int fd, struct strbuf *cntlptr, struct strbuf *dataptr, int *flags); poll():- The purpose of this function is to provide multiplexing. Syntax:- int poll(struct pollfd *fdarray, long nfds, int timeout); UNIX NETWORK PROGRAMMING UNIT-4 18Slide 19: TLI IMPLEMENTATION TLI is a library of ‘c’ functions. TLI provides a user interface to the implementation of various networking protocols. TLI handles the actual stream interface from the user. The following is the layered structure of TLI implementation. UNIX NETWORK PROGRAMMING UNIT-4 19 User code TLI functions STREAM HEAD Transport provider Device driver User code User code TLI functions TLI functions STREAM HEAD Transport provider Device driver A BSlide 20: If a process A executes some other process that will handle a transport endpoint. Since, TLI functions are part of the user process and not part of the kernel, the TLI data structures of process A for given endpoint disappear after exec(). The TLI functions in process B know nothing about the endpoint, but the endpoint is a valid transport endpoint, since the file descriptor to the streams device was passed from process A to process B across the exec() system call. UNIX NETWORK PROGRAMMING UNIT-4 20Slide 21: STREAM PIPES Stream pipe is a full duplex connection between two processes. Stream pipes are used in system for passing file descriptors between processes. i.e., at a time bidirectional transmission is provided. Stream pipes can be name and unnamed pipes. Named stream pipe:- It similar to FIFO and it is used by unrelated processes that wish to communicate. Unnamed stream pipe:- It can be used by a parent process that wants a stream pipe connection between itself and a child process. Stream pipes are implemented using a loop around driver. These are similar to unix domain sockets. UNIX NETWORK PROGRAMMING UNIT-4 21Slide 22: Implementation of stream pipes First a user process opens the loop device two times obtaining two file descriptors fdi and fdj. UNIX NETWORK PROGRAMMING UNIT-4 22 User process Stream head Stream head Loop driver Loop driverSlide 23: UNIX NETWORK PROGRAMMING UNIT-4 23 User process Stream head Stream head Loop driver Loop driver Next, the stream ioctl command I_FDINSERT connects the two file descriptors togetherSlide 24: Passing file descriptors:- It was implemented by system 5 IPC 3.0 by using two functions 1. send file and 2. receive file. When we want to pass a file from one process to another process , sending process open a file by using file descriptor generate id for system table. System table is a common area sharing both sending and receiving process. For example, sending process open a file descriptor 3 for a file and send file to system table. Reciving process open file descriptor 2, receive from file to system table, here sending and receiving process fds are not same i.e., sending and receiving fds are may or may not be same. To pass a file from one process to another process, two process must be connected unix domain socket. The connection must be either stream socket or datagram socket. Send message file by sndmsg() and receive file by rcvmsg(). Inode address *ptr contains all the information of system table i.e., size of the file send/receive and size of system table and base of the system table. UNIX NETWORK PROGRAMMING UNIT-4 24Slide 25: Input and output multiplexing:- Multiplexing input and output defined as multiple operations perform read, write operations in multiple sources i.e., buffer or single source. In TLI multiplexing implemented by poll function. The format of the system call is int poll(struct pollfd *fdarray, unsigned long nfds, int timeout); struct pollfd { int fd; int events; int revents; }; Here nfd represent number of file descriptors. Timeout represented as =0,>0,<0. >0-> represented as process without waited any time. =0-> represented as process waited some nano seconds. <0-> represented as process waited infinite time. UNIX NETWORK PROGRAMMING UNIT-4 25Slide 26: Asynchronous I/O:- An asynhcronous I/O can defined as data transfer between two different process in different speed in different clock cycles. In TLI asynchronous I/O provided by ioctl(). #include<stropts.h> int ioctl(int fd, int request, int arg); The arg is an integer value that specifies the conditions for which a SIGPOLL signal should be generated. Here request represented F_SETOWN i.e., communication between either single or multiple process and flag value is FASYC for asynchronous data transmission. UNIX NETWORK PROGRAMMING UNIT-4 26Slide 27: Out of band data in TLI:- When process received signal SIGURG that process can provided additional data is called out of band data or expired data. In TLI out of band data provided by t_snd(), t_rcv() functions. Set flag value msg_OOB. UNIX NETWORK PROGRAMMING UNIT-4 27 You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
PART-FOUR vadapally Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 147 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: June 16, 2011 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Slide 1: UNIT-4 TRANSPORT LAYER INTERFACE TLI (Transaction Layer Interface) is a form of IPC Provided with system V release 3.1. TLI provides communication between processes on the same system or on different systems. TLI was introduced with system V Release 3.0 in 1986. TLI provides interface to the transport layer of the OSI model and user process. TLI is a library functions, this library has linked externally by link editor. The functions in TLI are functions not system calls because TLI is a set of user-callable functions that hides the actual interface to the network system. There are two terms used in TLI. Transport end points Transport provider Transport endpoint:- The two processes that are communicating are called transport end points by TLI. Transport Provider:- It is a set of routines on the host computer that provide communication support for a user process. UNIX NETWORK PROGRAMMING UNIT-4 1Slide 2: TLI provides the interface between the user process and the transport provider. Transport endpoint addresses:- TLI imposes no restrictions on the structure of a transport address. This allows new protocols to be supported without requiring by kernel changes. TLI defines a generic structure that passes various data between the TLI functions and the user code. #include<tiuser.h> struct netbuf { unsigned int maxlen; unsigned int len; char *buf; }; These structures are always passed between the user and the TLI function by reference. This structure is similar to the sockaddr structure. UNIX NETWORK PROGRAMMING UNIT-4 2Slide 3: Elementary TLI functions:- TLI functions can be used for a connection oriented and connection less protocol. UNIX NETWORK PROGRAMMING UNIT-4 3 t_open () t_bind () t_alloc () t_listen () t_accept () t_rcv() t_snd() t_open () t_bind () t_alloc () t_connect() t_snd() t_rcv() Connection establishment Data (request) Data reply Connection oriented protocolSlide 4: UNIX NETWORK PROGRAMMING UNIT-4 4 t_open () t_bind () t_alloc () t_rcvudata () t_sndudata() t_open () t_bind () t_alloc () Data (request) Data reply Connection less protocol t_sndudata() t_rcvudata ()Slide 5: t_open():- To open the unix file that identifies the particular transport provider. It returns a file descriptor that is used by the other TLI functions. #include<tiuser.h> int t_open(char *pathname, int oflag, struct t_info *info); Where pathname depends on the details of the transport provider being used. Oflag argument specifies the flags, t_info is the structure. Struct t_info { long addr; /* max size of the transport protocol address */ long optional; /* max bytes of protocol specific options */ long tsdu; /* max size of transport service data unit*/ long etsdu; /* max size of expedited transport service data unit */ long connect; /* max amount of data on connection establishment*/ long discon; /* disconnected*/ long servtype; /* service type supported*/ }; Pathname can be /dev/tcp, /tcp/udp or /dev/ip. UNIX NETWORK PROGRAMMING UNIT-4 5Slide 6: Service type specifies the type of service and has three possibilites T_COTS connection oriented service, without orderly realease. T_COTS_ORD WITH ORDERLY REALEASE T_CLTS CONNECTION LESS SERVICE t_alloc():- It provides a dynamic allocation of TLI structures in which the sizes of all the buffers. i.e., the data is allocated at runtime for transport provider. Syntax:- #include<tiuser.h> char *t_alloc(int fd, int structtype, int fields); where fd is file descriptor and struct type specifies the type of data structure as struct type type of structure T_BIND struct t_bind T_CALL t_call T_DIS t_discon T_INFO t_info Fields argument specify space for one or nore netbuf structure. Fields are T_ALL, T_ADDR, T_OPT AND T_UDATA UNIX NETWORK PROGRAMMING UNIT-4 6Slide 7: t_free():- This function frees a structure that was previously allocated t_alloc. Syntax:- int t_free(char v*ptr, int struct type); t_free not only frees the memory that was allocated and also first checks any netbuf structures contained there in and releases the memory used by buffers. t_bind():- This function assigns an address to a transport endpoint. It specifies the local-addr and local-process elements of the association 5-tuple. Syntax:- int t_bind(int fd, struct t_bind *request, struct t_bind *return); Where fd specifies the transport end point and t_bind is a structure. Struct t_bind { struct netbuf addr; unsigned int qlen; }; UNIX NETWORK PROGRAMMING UNIT-4 7Slide 8: t_connect():- This function can be executed by client process in connection oriented service. The purpose of this function is to send request to the server process. Syntax:- int t_connect(int fd, struct t_call *sendcall, struct t_call *recvcall); Struct t_call { struct netbuf addr; struct netbuf opt; struct netbuf udata; /*user data*/ int sequence; /* applies only to t_listen() function*/ }; The send call structure specifies the information needed by the transport ptovider to establish the connection. The addr structure specifies the structure specifies the server address. The recvcall structure contains the information associated with the connection that is returned by transport provider to the caller. The caller can put NULL for this structure if the returns information regarding the connection is not desired. UNIX NETWORK PROGRAMMING UNIT-4 8Slide 9: t_listen():- This function can be used in connection oriented service server process to identify requests from clients. A connection oriented server waits for connection request t_listen function. Syntax:- int t_listen(int fd, struct t_call *call); It only waits but not accepts the connection. t_accept():- This function is executed by server process to establish connection between two different process i.e., server and client. Once the t_listen function indicates that a connection request has arrived. To accept the request the t_accept function is called. Syntax:- int t_accept(int fd, int connfd, struct t_call *call); Here fd argument specifies the transport end point where the connection request arrived. The connfd argument specifies the transport endpoint where the connection is to be established. UNIX NETWORK PROGRAMMING UNIT-4 9Slide 10: t_snd() and t_rcv():- These two functions send or receive either normal or expedited (out of band )data . The purpose of this function are perform I?O operation between client and server. Syntax:- int t_snd(int fd, char *buff, unsigned int nbytes, int flags); int t_rcv(int fd, char *buff, unsigned int nbytes, int *flags); t_close():- The purpose of this function is to close transport endpoint connection. Syntax:- int t_close(int fd); t_sndudata() and t_rcvudata():- These two functions are used for connection less protocols to send and receive datagrams. Syntax:- int t_sndudata(int fd, struct t_unitdata *unitdata); int t_rcvudata(int fd, struct t_unitdata *unitdata, int *flags); UNIX NETWORK PROGRAMMING UNIT-4 10Slide 11: Advanced TLI functions Nonblocking I/O:- The transport end point can be put into a nonblocking (no wait ) state. This state can be set, when the end point is created with t_open function with flag=O_NDELAY. When a transport end point is nonblocking, the following TLI function can return immediately. t_getinfo():- The purpose of this function is to retrieve information about transport provider. Syntax:- int t_getinfo(int fd, struct t_info *info); t_getstate():- this function returns the current state to the caller, integer value to the caller. Syntax:- int t_getstate(int fd); The states are T_DATAXFER data transfer T_INCON incoming pending for server T_IDLE bound, but idle T_INREL incoming orderly release T_OUTCON outgoing connection pending for client T_OUTREL, T_UNBIND UNIX NETWORK PROGRAMMING UNIT-4 11Slide 12: t_optmgmt():- This function enables the caller to fetch or set protocol dependent options. Syntax: #include<tiuser.h> int t_optmgmt(int fd, struct t_optmgmt *request, struct t_optmgmt *return); This function corresponds to the getsockopt and setsockopt socket calls. t_rcvconnect ():- This function allows a client to initiate a connection request asynchronously. Syntax:- int t_rcvconnect(int fd, struct t_call *recvcall); t_sync():- This function synchronizes the data structures maintained by the TLI library with the current state of the transport end point specified by fd. Syntax:- int t_sync(int fd); It also returns the current state of the endpoint as the value of the function. UNIX NETWORK PROGRAMMING UNIT-4 12Slide 13: t_ubind():- The purpose of this function is to unbind for transport provider i.e., when allocated name for bind function is free. Syntax:- int t_ubind(int fd); UNIX NETWORK PROGRAMMING UNIT-4 13Slide 14: STREAMS Streams implemented by system 5 release 3.0. streams provide a full-duplex connection between a user process and a device driver. UNIX NETWORK PROGRAMMING UNIT-4 14 USER PROCESS STREAMS SYSTEM CALL INTERFACE DEVICE DRIVERSlide 15: Stream converted into stream head to perform input and output operations. The following diagram shows the full duplex nature. The stream head performed operations into the buffer, that buff can be called as “Processing module”. The processing module implemented in between the stream head and device driver and provided multiplexing in streams by using communication protocol in TCP and IP. UNIX NETWORK PROGRAMMING UNIT-4 15 USER PROCESS Processing module DEVICE DRIVER USER PROCESS STREAM HEAD STREAM HEAD DEVICE DRIVERSlide 16: UNIX NETWORK PROGRAMMING UNIT-4 16 User process User process User process STREAM HEAD STREAM HEAD STREAM HEAD TCP MODULE IP MODULE ETHERNET DRIVER ETHERNET DRIVERSlide 17: FEATURE OF STREAMS Full-duplex connection Here device driver may be pseudo driver i.e., there is no requirement that if associate with hardware device. Process can add modules between the stream head and the device driver, any number of modules can ‘pushed’ on to a stream. (LIFO). i.e., each new module gets inserted just below the stream head. Streams provide a mice layered implementation of the networking system. The stream module that accepts data from multiple sources is called a multiplexor. In stream networking the device driver becomes the network interface( ethernet , device driver, token ring etc.,) and the processing modules between the stream head and device driver implement a communication protocol. Streams are accessed through the following standard system calls Open(), close(), read(), write(), ioctl (), putmsg (), getmsg () and poll(). The data transferred up and down a stream consists of messages, each message contains a two parts.1. control and 2. data part. UNIX NETWORK PROGRAMMING UNIT-4 17Slide 18: These messages can be read or write through getmsg(), putmsg() system calls. getmsg():- The purpose of this message is to retrieve message from processing module. Syntax:- #include<stropts.h> int getmsg(int fd, struct strbuf *cntlptr, struct strbuf *dataptr, int *flags); put msg():- To store message into processing module. This function contain data part and control part. Syntax:- #include<stropts.h> int putmsg(int fd, struct strbuf *cntlptr, struct strbuf *dataptr, int *flags); poll():- The purpose of this function is to provide multiplexing. Syntax:- int poll(struct pollfd *fdarray, long nfds, int timeout); UNIX NETWORK PROGRAMMING UNIT-4 18Slide 19: TLI IMPLEMENTATION TLI is a library of ‘c’ functions. TLI provides a user interface to the implementation of various networking protocols. TLI handles the actual stream interface from the user. The following is the layered structure of TLI implementation. UNIX NETWORK PROGRAMMING UNIT-4 19 User code TLI functions STREAM HEAD Transport provider Device driver User code User code TLI functions TLI functions STREAM HEAD Transport provider Device driver A BSlide 20: If a process A executes some other process that will handle a transport endpoint. Since, TLI functions are part of the user process and not part of the kernel, the TLI data structures of process A for given endpoint disappear after exec(). The TLI functions in process B know nothing about the endpoint, but the endpoint is a valid transport endpoint, since the file descriptor to the streams device was passed from process A to process B across the exec() system call. UNIX NETWORK PROGRAMMING UNIT-4 20Slide 21: STREAM PIPES Stream pipe is a full duplex connection between two processes. Stream pipes are used in system for passing file descriptors between processes. i.e., at a time bidirectional transmission is provided. Stream pipes can be name and unnamed pipes. Named stream pipe:- It similar to FIFO and it is used by unrelated processes that wish to communicate. Unnamed stream pipe:- It can be used by a parent process that wants a stream pipe connection between itself and a child process. Stream pipes are implemented using a loop around driver. These are similar to unix domain sockets. UNIX NETWORK PROGRAMMING UNIT-4 21Slide 22: Implementation of stream pipes First a user process opens the loop device two times obtaining two file descriptors fdi and fdj. UNIX NETWORK PROGRAMMING UNIT-4 22 User process Stream head Stream head Loop driver Loop driverSlide 23: UNIX NETWORK PROGRAMMING UNIT-4 23 User process Stream head Stream head Loop driver Loop driver Next, the stream ioctl command I_FDINSERT connects the two file descriptors togetherSlide 24: Passing file descriptors:- It was implemented by system 5 IPC 3.0 by using two functions 1. send file and 2. receive file. When we want to pass a file from one process to another process , sending process open a file by using file descriptor generate id for system table. System table is a common area sharing both sending and receiving process. For example, sending process open a file descriptor 3 for a file and send file to system table. Reciving process open file descriptor 2, receive from file to system table, here sending and receiving process fds are not same i.e., sending and receiving fds are may or may not be same. To pass a file from one process to another process, two process must be connected unix domain socket. The connection must be either stream socket or datagram socket. Send message file by sndmsg() and receive file by rcvmsg(). Inode address *ptr contains all the information of system table i.e., size of the file send/receive and size of system table and base of the system table. UNIX NETWORK PROGRAMMING UNIT-4 24Slide 25: Input and output multiplexing:- Multiplexing input and output defined as multiple operations perform read, write operations in multiple sources i.e., buffer or single source. In TLI multiplexing implemented by poll function. The format of the system call is int poll(struct pollfd *fdarray, unsigned long nfds, int timeout); struct pollfd { int fd; int events; int revents; }; Here nfd represent number of file descriptors. Timeout represented as =0,>0,<0. >0-> represented as process without waited any time. =0-> represented as process waited some nano seconds. <0-> represented as process waited infinite time. UNIX NETWORK PROGRAMMING UNIT-4 25Slide 26: Asynchronous I/O:- An asynhcronous I/O can defined as data transfer between two different process in different speed in different clock cycles. In TLI asynchronous I/O provided by ioctl(). #include<stropts.h> int ioctl(int fd, int request, int arg); The arg is an integer value that specifies the conditions for which a SIGPOLL signal should be generated. Here request represented F_SETOWN i.e., communication between either single or multiple process and flag value is FASYC for asynchronous data transmission. UNIX NETWORK PROGRAMMING UNIT-4 26Slide 27: Out of band data in TLI:- When process received signal SIGURG that process can provided additional data is called out of band data or expired data. In TLI out of band data provided by t_snd(), t_rcv() functions. Set flag value msg_OOB. UNIX NETWORK PROGRAMMING UNIT-4 27