EECS 123: Introduction to Real-Time Distributed Programming

Size: px
Start display at page:

Download "EECS 123: Introduction to Real-Time Distributed Programming"

Transcription

1 EECS 123: Introduction to Real-Time Distributed Programming Lecture : IP, UDP, TCP, RPC, and Time Measurement This slide-set was prepared by the Teaching Assistant, P. Athreya. * Most of the slides in this set have been borrowed from Dr. Behrouz Forouzan who is the author of the book, 'TCP/IP Protocol', pub. by McGraw Hill, 2000, and placed various related slides on the Web. UCI DREAM Lab 1 1. OSI and TCP/IP UCI DREAM Lab 2

2 The OSI Model 3 On the sending end each layer adds a header to the passed on to it by the upper layer and passes it to the lower layer. Eventually the data is transmitted as binary electrical signals. On the receiving end the reverse is done and the headers are stripped while moving up the layers. 4

3 Layers in the TCP/IP Structure HTTP 5 The different layers use different kinds of addresses for communication. 6

4 2. Data link layer Protocols UCI DREAM Lab 7 Ethernet is a data link layer protocol that controls the access to the physical medium. However it introduces collisions which can be minimized using CSMA/CD protocol ( Carrier Sense Multiple Access / Collision Detection) 8

5 The Ethernet packet is the unit of transmission at the physical layer. The data field is an IP packet of at least 46 bytes. The frame is the unit without the preamble and SFD (Start of Frame Delimiter) size is 64 bytes. Frame is the unit at the data link layer. CRC is the checksum which contains error checking code for the entire packet. 9 The token ring is another medium access control protocol. It doesn t introduce collisions but involves a token that circulates from one user to another. Dead? 10

6 The token ring packet structure contains a modified token. The token itself is only 3 bytes and when a machine wants to transmit, it modifies the token by only 1 bit and follows it up with the destination address, etc IP Addressing UCI DREAM Lab 12

7 The IP address has 4 bytes and has the structure X.X.X.X where 0< X < The IP addresses are classified into 5 different classes. Each class contains a group of address based on Netid which is assigned to a network. 14

8 15 4. Subnetting UCI DREAM Lab 16

9 Consider a Class B network as shown above. It is possible that the entire network is not used by a single organization. To facilitate networks smaller than the classes permit, this network can be subdivided as shown next. 17 So now smaller networks called subnetworks are possible from the same huge network as specified by a class. 18

10 So instead of only 2 parameters defining the network (netid & hostid) the subnetwork is defined by an additional parameter subnetid. However in practice both the netid and subnetid are replaced by the subnetmask. 19 Note that the subnet mask looks like an ip address and hence can have any value. E.G., a mask of will result in the ip address set x.x.y.z where x.x is the first part of the netid, y is an even number from 0 to 255 and z is any number from 0 to

11 A bitwise view of the subnetmask 21 Another subnet mask example. 22

12 5. Routing UCI DREAM Lab 23 Possible methods of delivery of IP packets. 24

13 Host A, Host B, R1, R2 are IP addresses. The figure shows 2 different methods of routing a. Routers keep the entire route to a destination in their table b. Routers only keep the neighboring routers in their table Internet Protocol (IP) UCI DREAM Lab 26

14 IP packet with the header in detail. 27 IP packets may have to be fragmented as they are transported from source to destination. The numbers in red are the offsets of the fragments. 28

15 Offset calculation. The division by 8 is done because the offset is only 13 bits while the total length of the packet is expressed in 16 bits ARP and RARP UCI DREAM Lab 30

16 ARP = Address Resolution Protocol RARP = Reverse Address Resolution Protocol 31 32

17 The purpose of ARP is to get the physical address ( e.g., Ethernet address) of the machine to which an IP packet is to be sent. When the source calls ARP, then either the destination node or a router responsible for routing packets to that node (or network containing that node) will respond. 33 RARP is used by a node to obtain its own IP address when it boots. E.G., a node without a hard disk may need this => Every time the node starts, it asks a RARP server for its IP address. 34

18 8. User Datagram Protocol (UDP) UCI DREAM Lab 35 36

19 37 38

20 39 9. Transmission Control Protocol (TCP) In this course, we will use UDP only. Why? High-precision timing control in message communication is harder with TCP than with UDP. UCI DREAM Lab 40

21 s 41 s 42

22 s The sliding window protocol is used in the TCP for keeping track of acknowledged packets. 43 s Window size = 10 44

23 s Congestion control is done by adjusting the window size. Window size is increased when the congestion is less. 45 s Congestion is reduced by decreasing the window size. 46

24 s The acknowledgement contains the sequence number to be transmitted next. The figure shows retransmission of a window segment in TCP. 47 s 48

25 s Domain Name System (DNS) UCI DREAM Lab 50

26 51 52

27 53 54

28 The client is looking for the IP address of mcgraw.com Socket Interface UCI DREAM Lab 56

29 Basic API Internet Address 57 Basic API in_addr This structure represents a host by its Internet address. typedef struct in_addr { union { struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b; struct { u_short s_w1, s_w2; } S_un_w; u_long S_addr; } S_un; } in_addr; 58

30 Basic API inet_addr () unsigned long inet_addr ( const char * cp ); Converts a string containing an Standard Internet dotted address (e.g ) into an address in IN_ADDR structure format. inet_ntoa () Converts an Internet address (in IN_ADDR structure format) into a string in Internet standard dotted format. 59 Address IP port IP address Padding Family Used to specify a local or remote endpoint address to which to connect a socket 60

31 Basic API SOCKADDR_IN This structure is used to specify a local or remote endpoint address to which to connect a socket. struct sockaddr_in { short sin_family; // Address family (must be AF_INET) unsigned short sin_port; // IP port struct in_addr sin_addr; // IP address. char sin_zero [8]; // Padding to make structure // the same size as SOCKADDR. }; 61 62

32 Basic Utility Functions A u_short from host to TCP/IP network byte order These functions are needed because the byte order of the data stored in memory depends on the host machine architecture. 63 Basic Utility Functions void *memset (void *dest, int c, size_t count); // Sets the first count bytes of dest to the character c. // e.g. memset ( buffer, '*', 4 ); // size_t is same as unsigned integer. // dest - Pointer to destination. // count - Number of characters void *memcpy (void *dest, const void *src, size_t count); // Copies count bytes of src to dest. // dest - Pointer to destination. // src Pointer to source (buffer to copy from). // count - Number of characters to copy. int memcmp (const void *buf1, const void *buf2, size_t count); // Compares the first count bytes of buf1 and buf2 and returns a value indicating // their relationship. // buf1 Pointer to first buffer. buf2 - Pointer to second buffer. // count - Number of bytes. // Return Value < 0 means buf1 less than buf2 // Return Value = 0 means buf1 identical to buf2 // Return Value > 0 means buf1 greater than buf2 64

33 Basic Utility Functions MAKEWORD This macro creates an unsigned 16-bit integer by concatenating two specified unsigned character values. WORD MAKEWORD ( BYTE blow, // The low-order byte of the new short value BYTE bhigh // The high-order byte of the new short value ); 65 Basic API Retrieves host information corresp to a host name from a host DB 66

34 Basic API AF stands for Address Family AF_APPLETALK - value is 16 and stands for AppleTalk protocols AF_INET - value is 2 and stands for Inter-network (UDP, TCP, etc) 67 Basic API hostent Structure used to store information about a given host, such as host name, IP address, etc. typedef struct hostent { char * h_name; char ** h_aliases; short h_addrtype; short h_length; char ** h_addr_list; } hostent; h_name - Official name of the host (PC) h_aliases - Null-terminated array of alternate names. h_addrtype - Type of address being returned. (e.g. AF_INET) h_length - Length of each address, in bytes. h_addr_list - Null-terminated list of addresses for the host. Addresses are returned in network byte order. 68

35 Basic API socket 69 Basic API Socket () This (Windows Sockets) socket function creates a socket that is bound to a specific service provider. SOCKET socket ( int af, // address family specification int type, // type specification for the new socket // only two type specifications supported for // Windows Sockets 1.1 : // SOCK_STREAM (for TCP, value is 1) and // SOCK_DGRAM (for UDP, value is 2). int protocol // A particular protocol to be used with the socket // that is specific to the indicated address family ); 70

36 Basic API Setsockopt () This (Windows Sockets) setsockopt function sets a socket option. int setsockopt ( SOCKET s, // Identifies a socket int level, // Indicates the supported level of Socket. // The levels include SOL_SOCKET (value 0xffff) int optname, // Specifies the socket option. //E.G., SO_BROADCAST (value 0x0020) const char * optval, int optlen ); 71 Basic API Setsockopt () There are two types of socket options: Boolean options that enable or disable a feature or behavior Options that require an integer value or structure. To enable a Boolean option, optval points to a non-zero integer. To disable the option, optval points to an integer equal to zero. The optlen parameter should be equal to sizeof (int) for Boolean options. For other options, optval points to the an integer or structure that contains the desired value for the option, and optlen is the length of the integer or structure. 72

37 connect listen ; accept 73 Basic API (socket The bind function binds a newly created socket to a local address. Server uses this to associate a local address with a socket 74

38 Basic API bind () The (Windows Sockets) bind function associates a local address with a socket. int bind ( SOCKET s, // Identifies an unbound socket const struct sockaddr * name, // The address to assign to the socket. // ADDR_ANY or INADDR_ANY is specified, if you do // not care to which address the socket is bound to. // ADDR_ANY and INADDR_ANY stands for // (u_long) 0x int namelen // Length of the name ); 75 76

39 77 78

40 Basic API (socket Enters a listening mode listen () The (Windows Sockets) listen function places a socket in a state where it is listening for an incoming connection. int listen ( SOCKET s, int backlog // The maximum length of the queue of // pending connections ); 79 Basic API (socket Connect () A client uses this to connect to an existing socket The (Windows Sockets) connect function establishes a connection to a specified socket. int connect ( SOCKET s, // Identifies an unconnected socket const struct sockaddr * name, // Specifies the name of the socket to connect to int namelen // Length of the name parameter ); When the connect call completes successfully, it returns zero and the socket is ready to send/receive data. 80

41 Basic API (socket Permits an incoming connection attempt on a socket Accept () The (Windows Sockets) accept function accepts an incoming connection attempt on a socket. SOCKET accept ( SOCKET s, // Identifying a socket that has been placed in a // listening state with the listen function struct sockaddr * addr, // Optional pointer to a buffer that receives the // address of the connecting entity int * addrlen // Optional pointer to an integer that contains // the length of the address addr ); 81 Basic API Accept () The (Windows Sockets) accept function accepts an incoming connection attempt on a socket. SOCKET accept ( SOCKET s, // Identifying a socket that has been placed in a // listening state with the listen function struct sockaddr * addr, // Optional pointer to a buffer that receives the // address of the connecting entity int * addrlen // Optional pointer to an integer that contains // the length of the address addr ); 82

42 Basic API send () The (Windows Sockets) send function sends data on a connected socket. int send ( SOCKET s, // Identifies a connected socket const char * buf, // Specifies the buffer containing // the data to be transmitted int len, // The length of the data in buf int flags // An indicator specifying the way in which // the call is made. The default value is zero // which means that no options are set. ); 83 (socket Basic API sendto () Sends data to a specific destination The (Windows Sockets) sendto function sends data to a specific destination. int sendto ( SOCKET s, // Identifies a (possibly unconnected) socket const char * buf, // Specifies the buffer containing // the data to be transmitted int len, // The length of the data in buf. int flags, // Default : zero := No options are set. const struct sockaddr * to, //optional pointer to the address of the target socket int tolen // The size of the address in to ); 84

43 recv (socket Basic API recv () The (Windows Sockets) recv function receives data from a connected socket. int recv ( SOCKET s, // Identifies a connected socket char * buf, // Specifies a buffer for the incoming data int len, // The length of buf int flags // Flag specifying the way in which the call // is made. Default value is zero. ); 85 (socket Basic API recvfrom () The (Windows Sockets) recvfrom function receives a datagram and stores the source address. int recvfrom ( SOCKET s, // Identifies a bound socket char * buf, // Specifies a buffer for the incoming data int len, // The length of buf int flags struct sockaddr * from, // Optional pointer to a buffer that // will hold the source address int * fromlen // Optional pointer to the size of the from buffer ); 86

44 Basic API shutdown () The (Windows Sockets) shutdown function disables sends or receives on a socket. This function is used on all types of sockets to disable reception, transmission, or both. int shutdown ( SOCKET s, int how // how parameter is SD_RECEIVE (value is zero): // subsequent calls to the recv () function on the socket // will be disallowed. // how parameter is SD_SEND (value is One): // subsequent calls to the send () function are disallowed. // how is SD_BOTH (value is two): both send () and // recv () will be disabled. ); 87 Basic API Closesocket () The (Windows Sockets) closesocket function closes an existing socket. int closesocket ( SOCKET s ); Returns 0 if successful; -1 if error. 88

45 WSADATA This structure is used to store Windows Sockets initialization data returned by a call to WSAStartup. It contains data about the Winsock.dll implementation. struct WSAData { }; Basic API WORD wversion; // Version of Windows Sockets spec that caller uses WORD whighversion; // Highest version of Windows Sockets // specification that this DLL can support char szdescription [WSADESCRIPTION_LEN + 1]; // string into which the Windows Sockets DLL copies // a description of the Windows Sockets implementation char szsystemstatus [WSASYSSTATUS_LEN + 1]; // string into which Sockets DLL copies status unsigned short imaxsockets; // Max number of sockets which a // single process can open unsigned short imaxudpdg; // Size, in bytes, of the largest UDP // datagram that can be sent or received by a WinSock appl. char * lpvendorinfo; // Long pointer to a vendor-specific data structure 89 90

46 12. TCP/IP Sample Program UCI DREAM Lab 91 s /****************************/ //sockserver.cpp /***************************/ #include <winsock2.h> #include <stdio.h> #include <iostream.h> void main() { SOCKET sendsock; SOCKADDR_IN sendsockaddr; int port = 4031; WSADATA Data; int status = WSAStartup (MAKEWORD(1, 1), &Data); // Initialize Winsock.dll vers 1.1. // This function must be the first Windows Sockets // function called by an application or DLL. if ( status!= 0 ) { printf ("ERROR: WSAStartup unsuccessful. We couldn't find a Winsock DLL (version 1.1)\n"); return; 92 }

47 s memset (&sendsockaddr, 0, sizeof(sendsockaddr)); sendsockaddr.sin_port = htons (port); sendsockaddr.sin_family = AF_INET; sendsockaddr.sin_addr.s_addr = htonl (ADDR_ANY); // Finds a local IP addr sendsock = socket (AF_INET, SOCK_STREAM, 0); // A TCP socket is created. if ( sendsock == INVALID_SOCKET ) // INVALID_SOCKET is 0. { printf ("ERROR: socket creation unsuccessful\n"); } status = bind (sendsock, (LPSOCKADDR) &sendsockaddr, sizeof (sendsockaddr)); // The socket is bound to a local address. if ( status == SOCKET_ERROR ) printf ("ERROR: bind unsuccessful %d\n ", WSAGetLastError()); 93 s listen (sendsock,0); // The number of pending connections // allowed is set to zero. printf ("accepting...\n"); SOCKET sendsock2 = accept (sendsock,0,0); // A blocking call if ( sendsock2 == INVALID_SOCKET ) printf ("ERROR: accept unsuccessful %d\n", WSAGetLastError()); printf ("sending...\n"); Sleep (2000); Two-way int send_data = 100; int numsnt = send (sendsock2, (char*) &send_data, sizeof(send_data), 0); // The data is sent through the socket and send () // returns the number of bytes sent. if ( numsnt == SOCKET_ERROR ) cout << "ERROR: send unsuccessful\n" << WSAGetLastError() << endl cout << "data sent = " << send_data << endl; } Sleep (3000); 94

48 s /****************************/ //sockclient.cpp /***************************/ #include <winsock2.h> #include <stdio.h> #include <iostream.h> void main() { SOCKET recvsock; SOCKADDR_IN recvsockaddr; int port = 4031; WSADATA Data; int status = WSAStartup (MAKEWORD(1, 1), &Data); // Initialize Winsock.dll if ( status!= 0 ) { printf ("ERROR: WSAStartup unsuccessful. We couldn't find a Winsock DLL (version 1.1)\n"); return; } 95 s memset (&recvsockaddr, 0, sizeof (recvsockaddr) ); recvsockaddr.sin_port = htons (port); recvsockaddr.sin_family = AF_INET; recvsockaddr.sin_addr.s_addr = inet_addr (" "); // inet_addr function converts the IP address into // in_addr struct format. recvsock = socket (AF_INET, SOCK_STREAM, 0); // A TCP socket is created. if ( recvsock == INVALID_SOCKET ) { printf ("ERROR: socket creation unsuccessful\n"); } 96

49 printf ("connecting...\n"); s status = connect (recvsock, (LPSOCKADDR) &recvsockaddr, sizeof (recvsockaddr) ); if ( status == SOCKET_ERROR ) printf ("ERROR: connect unsuccessful %d\n", WSAGetLastError() ); int recv_data; printf ("receiving...\n"); int numrcv = recv (recvsock, (char*) &recv_data, sizeof (recv_data), 0); if ( numrcv == SOCKET_ERROR numrcv!= sizeof(recv_data)) { printf ("ERROR: recvfrom unsuccessful\n"); int errorcode = WSAGetLastError(); printf ("Error Code = %d\n", errorcode ); } cout << "data received = " << recv_data << endl; } Sleep(5000); UDP Sample Program UCI DREAM Lab 98

50 /****************************/ //socksendudp.cpp /***************************/ #include <winsock2.h> #include <stdio.h> #include <iostream.h> void main() { SOCKET sendsock; SOCKADDR_IN sendsockaddr; SOCKET recvsock; SOCKADDR_IN recvsockaddr; int port1 = 4031; int port2 = 4032; WSADATA Data; int status = WSAStartup (MAKEWORD(1, 1), &Data); // Init Winsock.dll if ( status!= 0 ) printf ("ERROR: WSAStartup unsuccessful. We couldn't find a Winsock DLL (version 1.1)\n"); 99 memset (&sendsockaddr, 0, sizeof (sendsockaddr) ); sendsockaddr.sin_port = htons (port1); sendsockaddr.sin_family = AF_INET; sendsockaddr.sin_addr.s_addr = htonl (INADDR_BROADCAST); // INADDR_BROADCAST stands for 0xffffffff sendsock = socket (AF_INET, SOCK_DGRAM, 0); if ( sendsock == INVALID_SOCKET ) { printf ("ERROR: socket creation unsuccessful\n", WSAGetLastError());} int enable = 1; // Permit sending of broadcast msgs status = setsockopt (sendsock, SOL_SOCKET, SO_BROADCAST, (char *) &enable, sizeof(int)); // The socket is set as a broadcast socket if ( status == SOCKET_ERROR ) printf ("ERROR: bind unsuccessful\n", WSAGetLastError()); 100

51 memset (&recvsockaddr, 0, sizeof(recvsockaddr)); recvsockaddr.sin_port = htons (port2); recvsockaddr.sin_family = AF_INET; recvsockaddr.sin_addr.s_addr = htonl (INADDR_ANY); recvsock = socket (AF_INET, SOCK_DGRAM, 0); // A UDP socket is created. if ( recvsock == INVALID_SOCKET ) { printf ("ERROR: socket creation unsuccessful\n", WSAGetLastError()); return; } status = bind (recvsock, (LPSOCKADDR) &recvsockaddr, sizeof (recvsockaddr) ); // The socket is bound to a local address. if ( status == SOCKET_ERROR ) printf ("ERROR: bind unsuccessful\n", WSAGetLastError()); printf ("sending data...\n"); Sleep(2000); 101 } int send_data = 100; int numsnt = sendto ( sendsock, (char*) &send_data, sizeof (send_data),0, (LPSOCKADDR) &sendsockaddr, sizeof (sendsockaddr) ); if ( numsnt == SOCKET_ERROR ) printf ("ERROR: Broadcast sendto unsuccessful\n", WSAGetLastError()); cout << "data sent = " << send_data << endl; printf ("receiving acknowlegdement...\n"); int recv_ack; int numrcv = recvfrom (recvsock, (char*) &recv_ack, sizeof (recv_ack), 0, NULL, NULL); if ( numrcv == SOCKET_ERROR numrcv!= sizeof(recv_ack)) printf ("ERROR: recvfrom unsuccessful\n", WSAGetLastError()); cout << "acknowlegdement received = " << recv_ack << endl; Sleep(3000); 102

52 /****************************/ //sockrecvudp.cpp /***************************/ #include <winsock2.h> #include <stdio.h> #include <iostream.h> void main () { SOCKET sendsock; SOCKADDR_IN sendsockaddr; SOCKET recvsock; SOCKADDR_IN recvsockaddr; int port1 = 4031; int port2 = 4032; WSADATA Data; int status = WSAStartup (MAKEWORD(1, 1), &Data); // Init Winsock.dll if ( status!= 0 ) { printf ("ERROR: WSAStartup unsuccessful. We couldn't find a Winsock DLL (version 1.1)\n"); return; } memset (&sendsockaddr, 0, sizeof(sendsockaddr)); sendsockaddr.sin_port = htons (port2); sendsockaddr.sin_family = AF_INET; sendsockaddr.sin_addr.s_addr = htonl (INADDR_BROADCAST); 103 sendsock = socket(af_inet, SOCK_DGRAM, 0); if ( sendsock == INVALID_SOCKET ) { printf("error: socket creation unsuccessful\n", WSAGetLastError()); } int enable = 1; // Permit sending of broadcast msgs status = setsockopt (sendsock, SOL_SOCKET, SO_BROADCAST, (char*) &enable, sizeof(int)); if ( status == SOCKET_ERROR ) printf ("ERROR: bind unsuccessful\n", WSAGetLastError()); memset (&recvsockaddr, 0, sizeof(recvsockaddr)); recvsockaddr.sin_port = htons (port1); recvsockaddr.sin_family = AF_INET; recvsockaddr.sin_addr.s_addr = htonl (INADDR_ANY); recvsock = socket (AF_INET, SOCK_DGRAM, 0); if ( recvsock == INVALID_SOCKET ) { printf ("ERROR: socket creation unsuccessful\n", WSAGetLastError()); return; } status = bind (recvsock, (LPSOCKADDR) &recvsockaddr, sizeof(recvsockaddr)); if ( status == SOCKET_ERROR ) printf ("ERROR: bind unsuccessful\n", WSAGetLastError()); 104

53 printf ("receiving data...\n"); int recv_data; int numrcv = recvfrom (recvsock, (char*) &recv_data, sizeof(recv_data), 0, NULL, NULL); if ( numrcv == SOCKET_ERROR numrcv!= sizeof(recv_data)) printf ("ERROR: recvfrom unsuccessful\n", WSAGetLastError()); cout << "data received = " << recv_data << endl; printf ("sending acknowlegdement...\n"); Sleep(2000); int send_ack = 101; int numsnt = sendto ( sendsock, (char*) &send_ack, sizeof (send_ack),0, (LPSOCKADDR) &sendsockaddr, sizeof (sendsockaddr)); if ( numsnt == SOCKET_ERROR ) printf ("ERROR: Broadcast sendto unsuccessful\n", WSAGetLastError()); cout << "acknowlegdement sent = " << send_ack << endl; } Sleep(3000); Remote Procedure Call (RPC) UCI DREAM Lab 106

54 Remote Procedure Call (RPC) Make it appear to users as though a client directly calls a procedure located in a remote server program. The client and server each have their own address spaces Each has its own memory resource allocated to data used by the procedure. 107 RPC Calling Sequence The client application calls a local stub procedure instead of the actual code implementing the procedure. Client stubs are compiled and linked with the client application. Retrieves the required parameters from the client address space. Translates the parameters as needed into a standard NDR format for transmission over the network. Calls functions in the RPC client run-time library to send the request and its parameters to the server. The server performs the following steps to call the remote procedure. The server RPC run-time library functions accept the request and call the server stub procedure. The server stub retrieves the parameters from the network buffer and converts them from the network transmission format to the format the server needs. The server stub calls the actual procedure on the server. 108

55 When the remote procedure is complete, output parameters and a return value are sent to the client. The remote procedure returns its data to the server stub. The server stub converts output parameters to the format required for transmission over the network and returns them to the RPC run-time library functions. The server RPC run-time library functions transmit the data on the network to the client computer. The client completes the process by accepting the data over the network and returning it to the calling function. The client RPC run-time library receives the remote-procedure return values and returns them to the client stub. The client stub converts the data from its NDR to the format used by the client computer. The stub writes data into the client memory and returns the result to the calling program on the client. The calling procedure continues as if the procedure had been called on the same computer. RPC Result Return 109 Remote Procedure Call (RPC) Looks like a function call Combines Request and Reply En- / De-codes and transmits parameters and return values Example RPC mechanisms Sun RPC (RFC 1050), Xerox Courier One-way RPC does not involve return values from the remote server. Is it a slightly higher-level mechanism than a request message? More often than not, one-way RPC is more useful than two-way RPC is in RT distributed computing. Going a step further results in a remote method call among distributed computing objects Java RMI CORBA 110

56 Remote Procedure Call (RPC) A narrow view: Single thread of control split between two processes A broader view: Non-blocking service request (SR) is allowed as an instance of RPC. No shared global variables Pragmatic to recognize the possibility of network or remote server failing Use of timeouts is useful. Usually an order-of-magnitude slower than a local function call In some environments, authentication may be involved

57 Time Measurement UCI DREAM Lab 114

58 The system can be measured using the following system call GetSystemTime (SYSTEMTIME* lpsystemtime) This is Win32 API useful on windows based systems. Similar calls are available for other OSs. This function returns the current system time and stores into the SYSTEMTIME structure. typedef struct _SYSTEMTIME { WORD wyear; WORD wmonth; WORD wdayofweek; WORD wday; WORD whour; WORD wminute; WORD wsecond; WORD wmilliseconds; } SYSTEMTIME, *PSYSTEMTIME; Note that the time returned has millisecond level precision. 115 Using this function one can measure the time taken to complete a synchronous Remote Procedure Call as follows : GetSystemTime (systemtime_before_call); Result = Remote_Procedure_Call (possible_parameters); GetSystemTime (systemtime_after_call); RPC_time = Difference_of (systemtime_after_call, systemtime_before_call); Note the difference of the time is not a direct subtraction since these are structures. So before the subtraction, Convert the SYSTEMTIME structure to a FILENAME structure. Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. Use normal subtraction on the ULARGE_INTEGER value. 116

59 typedef struct _FILETIME { DWORD dwlowdatetime; DWORD dwhighdatetime; } FILETIME, *PFILETIME; typedef union _ULARGE_INTEGER { struct { DWORD LowPart; DWORD HighPart; }; ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; 117 In order to measure the time taken to send/receive messages on the network, first the round trip time is measured as follows Process 1 systemtime_before_send systemtime_before_receive 1 2 Process 2 (on another machine) Process 2 is waiting to receive. As soon as it receives a message, it sends a reply. 118

60 Process 1 : GetSystemTime (systemtime_before_send); send (message); // send message to Process 2 either // through a TCP or UDP connection receive (reply); // receive reply from Process 2 either // through a TCP or UDP connection GetSystemTime (systemtime_after_receive); Round_trip_time = Difference_of (systemtime_after_receive, systemtime_before_send); One_way_trip_time = Round_trip_time/2; Process 2 : receive (message); // wait to receive message from Process 2 send (reply); // on receiving the message reply to // Process 1 The one_way_trip_time is approximately the time taken to send/receive a message. Of course this value is not always true but several measurements of this value can be used to estimate the average and worst case values. 119 References [For00] Behrouz Forouzan, 'TCP/IP Protocol', pub. by McGraw Hill,

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics WinSock What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics What Is Sockets Standard API (Application Programming Interface) for

More information

A. Basic Function Calls for Network Communications

A. Basic Function Calls for Network Communications IV. Network Programming A. Basic Function Calls for Network Communications 1 B. Settings for Windows Platform (1) Visual C++ 2008 Express Edition (free version) 2 (2) Winsock Header and Libraries Include

More information

Socket Programming TCP UDP

Socket Programming TCP UDP Socket Programming TCP UDP Introduction Computer Network hosts, routers, communication channels Hosts run applications Routers forward information Packets: sequence of bytes contain control information

More information

Socket Programming for TCP and UDP

Socket Programming for TCP and UDP CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming

More information

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar - Advanced Data Communications:

More information

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005 Followup symbolic link (soft link): pathname, can be across file systems, replacement of file will be active on all symbolic links, consumes at least an inode. hard link: pointers to an inode, only in

More information

SOCKETS. COMP750 Distributed Systems

SOCKETS. COMP750 Distributed Systems SOCKETS COMP750 Distributed Systems Sockets The Socket library is a traditional Application Program Interface (API) to the transport layer. Sockets were originally implemented in Unix systems and have

More information

Network Communication

Network Communication Network Communication Processes communicating Process: program running within a host. q within same host, two processes communicate using inter- process communica6on (defined by OS). q processes in different

More information

Unix Network Programming

Unix Network Programming Introduction to Computer Networks Polly Huang EE NTU Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide to Network Programming 1 The Unix Socket A file descriptor

More information

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013 Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different

More information

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme Socket Programming Dr. -Ing. Abdalkarim Awad Informatik 7 Rechnernetze und Kommunikationssysteme Before we start Can you find the ip address of an interface? Can you find the mac address of an interface?

More information

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

CSC209H Lecture 9. Dan Zingaro. March 11, 2015 CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess

More information

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C 1 CSIS0234A Computer and Communication Networks Socket Programming in C References Beej's Guide to Network Programming Official homepage: http://beej.us/guide/bgnet/ Local mirror http://www.cs.hku.hk/~c0234a/bgnet/

More information

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements Announcements CS 5565 Network Architecture and Protocols Lecture 5 Godmar Back Problem Set 1 due Feb 17 Project 1 handed out shortly 2 Layer The Layer Let s look at some s (in keeping with top-down) architectures:

More information

CS321: Computer Networks Socket Programming

CS321: Computer Networks Socket Programming CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs

More information

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Ports under 1024 are often considered special, and usually require special OS privileges to use. 1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's

More information

A Client-Server Exchange

A Client-Server Exchange Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends

More information

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software Session NM056 Programming TCP/IP with Sockets Geoff Bryant Process software Course Roadmap Slide 57 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server

More information

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications

More information

CS321: Computer Networks Introduction to Application Layer

CS321: Computer Networks Introduction to Application Layer CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server

More information

Oral. Total. Dated Sign (2) (5) (3) (2)

Oral. Total. Dated Sign (2) (5) (3) (2) R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer

More information

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles LABORATORY SOCKET PROGRAMMING What is a socket? Using sockets Types (Protocols) Associated functions Styles 2 WHAT IS A SOCKET? An interface between application and network The application creates a socket

More information

CSE 124 Discussion Section Sockets Programming 10/10/17

CSE 124 Discussion Section Sockets Programming 10/10/17 CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code

More information

Introduction to Socket Programming

Introduction to Socket Programming UNIT II - ELEMENTARY TCP SOCKETS Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket,

More information

The User Datagram Protocol

The User Datagram Protocol The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.

More information

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani Titolo presentazione Piattaforme Software per la Rete sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Outline 1) Introduction to Sockets 2) UDP communication 3) TCP communication 4) RAW

More information

Department of Computer Science

Department of Computer Science Department of Computer Science Notes on Interprocess Communication in Unix Jean Dollimore,Oct.1990, last revised Feb. 1996 These notes explain how you can write "distributed programs" in C or C++ running

More information

Socket Programming(2/2)

Socket Programming(2/2) Socket Programming(2/2) 1 Outline 1. Introduction to Network Programming 2. Network Architecture Client/Server Model 3. TCP Socket Programming 4. UDP Socket Programming 5. IPv4/IPv6 Programming Migration

More information

Sockets 15H2. Inshik Song

Sockets 15H2. Inshik Song Sockets 15H2 Inshik Song Internet CAU www server (www.cau.ac.kr) Your web browser (Internet Explorer/Safari) Sockets 2 How do we find the server? Every computer on the Internet has an Internet address.

More information

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket

More information

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services. 15-213 The course that gives CMU its Zip! Network programming Nov 27, 2001 Topics Client- model Sockets interface Echo and Client- model Every network application is based on the - model: Application is

More information

EEC-484/584 Computer Networks

EEC-484/584 Computer Networks EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer

More information

UDP CONNECT TO A SERVER

UDP CONNECT TO A SERVER UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.

More information

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018 CS 43: Computer Networks 05: Socket Programming September 12-14, 2018 Reading Quiz Lecture 5/6 - Slide 2 Socket Programming Adapted from: Donahoo, Michael J., and Kenneth L. Calvert. TCP/IP sockets in

More information

Programming with TCP/IP. Ram Dantu

Programming with TCP/IP. Ram Dantu 1 Programming with TCP/IP Ram Dantu 2 Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a

More information

Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright Clifford Slocombe

Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright Clifford Slocombe Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright 2002 - Clifford Slocombe sockets@slocombe.clara.net COPYRIGHT 2002 - CLIFFORD SLOCOMBE PAGE 1 OF 8 Table of Contents Introduction...3

More information

CLIENT-SIDE PROGRAMMING

CLIENT-SIDE PROGRAMMING CLIENT-SIDE PROGRAMMING George Porter Apr 11, 2018 ATTRIBUTION These slides are released under an Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Creative Commons license These slides

More information

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory Socket Programming Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2019 Networking Laboratory Contents Goals Client-Server mechanism Introduction to socket Programming with socket on

More information

Chapter 6. The Transport Layer. Transport Layer 3-1

Chapter 6. The Transport Layer. Transport Layer 3-1 Chapter 6 The Transport Layer Transport Layer 3-1 Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems

More information

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation Lecture 2 Outline Wireshark Project 1 posted, due in a week Lab from a different textbook Work through the lab and answer questions at the end Chapter 1 - Foundation 1.1 Applications 1.2 Requirements 1.3

More information

CS 3516: Computer Networks

CS 3516: Computer Networks Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top

More information

CSCE 463/612 Networks and Distributed Processing Spring 2017

CSCE 463/612 Networks and Distributed Processing Spring 2017 CSCE 463/612 Networks and Distributed Processing Spring 2017 Preliminaries II Dmitri Loguinov Texas A&M University January 19, 2017 1 Agenda HTTP basics Windows sockets Clients 2 HTTP Basics General URL

More information

Network programming(i) Lenuta Alboaie

Network programming(i) Lenuta Alboaie Network programming(i) Lenuta Alboaie adria@info.uaic.ro 2017 2018 Computer Network http://www.info.uaic.ro/~computernetworks 1 Content Client/server paradigm API for network programming BSD Socket Characteristics

More information

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs Introduction to Unix Network Programming Reference: Stevens Unix Network Programming How do we Communicate? Send a mail from Alice to Bob Bob Alice in Champaign, Bob in Hollywood Example: US Postal Service

More information

Tutorial on Socket Programming

Tutorial on Socket Programming Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Hao Wang (Slides are mainly from Seyed Hossein Mortazavi, Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client-server

More information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University  Embedded Software Lab. 1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over

More information

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Sockets Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Internet Connections (1) Connection Clients and servers communicate by sending streams of

More information

Client Server Computing

Client Server Computing Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a remote computer. Instead, two application

More information

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups) The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1 Work Individually (no groups) Due Date: in class, Monday, September 19 Robert T Olsen olsen@cswiscedu 7390CS Office Hours: 3-5T, 11-12F - exception

More information

CS 640: Computer Networking

CS 640: Computer Networking CS 640: Computer Networking Yu-Chi Lai Lecture 3 Network Programming Topics Client-server model Sockets interface Socket primitives Example code for echoclient and echoserver Debugging With GDB Programming

More information

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel Internettechnologien (CS262) Socket Programming in C 4. März 2015 Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

More information

STUDY OF SOCKET PROGRAMMING

STUDY OF SOCKET PROGRAMMING STUDY OF SOCKET PROGRAMMING Sockets : An application programming interface(api) used for inter process communication. Sockets allow communication between two different processes on the same or different

More information

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! Lecture 5 Overview! Last Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book! This Lecture! Socket options! Source: Chapter 7 of Stevens book! Elementary UDP sockets! Source: Chapter 8 of Stevens

More information

Introduction to Computer Networks

Introduction to Computer Networks Introduction to Computer Networks Tian Song ( 嵩天 ), Ph.D., Assoc. Prof. songtian@bit.edu.cn Introduction to Computer Networks Socket and Network Programming Tian Song ( 嵩天 ), Ph.D., Assoc. Prof. songtian@bit.edu.cn

More information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 6 September 2018 Announcements Homework 1 will be posted. Will be on website, will announce

More information

UNIT IV- SOCKETS Part A

UNIT IV- SOCKETS Part A 1. Define sockets - SOCKETS Part A A socket is a construct to provide a communication between computers. It hides the underlying networking concepts and provides us with an interface to communicate between

More information

Network Socket Programming - 3 BUPT/QMUL

Network Socket Programming - 3 BUPT/QMUL Network Socket Programming - 3 BUPT/QMUL 2018-04-02 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface

More information

Announcements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)

Announcements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2) Announcements CS 5565 Network Architecture and Protocols Problem Set 1 due Feb 18 Project 1A due Feb 19 Lecture 5 Godmar Back 2 Queuing Demultiplexing send queues Layer k+1 Layer k recv queues End systems

More information

Application Programming Interfaces

Application Programming Interfaces Application Programming Interfaces Stefan D. Bruda Winter 2018 SYSTEM CALLS Machine 1 Machine 2 Application 1 Application 3 Application 4 Application 5 Application 2 API (system functions) API (system

More information

Network Socket Programming - 3 BUPT/QMUL

Network Socket Programming - 3 BUPT/QMUL Network Socket Programming - 3 BUPT/QMUL 2017-3-27 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface

More information

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~ Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will

More information

Part II: The Winsock API

Part II: The Winsock API Part II: The Winsock API Part II of this book is dedicated to Winsock programming on Win32 platforms. Winsock is the preferred interface for accessing a variety of underlying network protocols and is available

More information

Network Programming November 3, 2008

Network Programming November 3, 2008 15-213 Network Programming November 3, 2008 Topics Programmer s view of the Internet (review) Sockets interface Writing clients and servers class20.ppt A Client-Server Transaction Most network applications

More information

Group-A Assignment No. 6

Group-A Assignment No. 6 Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text

More information

2007 Microsoft Corporation. All rights reserved.

2007 Microsoft Corporation. All rights reserved. Creating a Basic Winsock Application 2007 Microsoft Corporation. All rights reserved. To create a basic Winsock application 1. Create a new empty project. 2. Add an empty C++ source file to the project.

More information

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm CS118 Discussion 1B, Week 1 Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm 1 TA Taqi, PhD student in Computer Networking Discussion (1B): Bunche 1209, Fri 12:00 1:50 p.m. Office hours: Boelter Hall

More information

Elementary TCP Sockets

Elementary TCP Sockets Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel

More information

1. Purpose. 2. Description Run-Time Issues Overview

1. Purpose. 2. Description Run-Time Issues Overview 1. Purpose CPS 470/570: Computer Networks Assignment 4, due 11:55 PM, 4-19-2017 Receive an F for this course if dishonesty occurs Receive 5 bonus points if submit it without errors one day before the deadline

More information

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1 Lecture 24 Log into Linux. Copy directory /home/hwang/cs375/lecture24 Final project posted. Due during finals week. Reminder: No class next Tuesday (11/24) Questions? Thursday, November 19 CS 375 UNIX

More information

The TCP Protocol Stack

The TCP Protocol Stack The TCP Protocol Stack Michael Brockway February 16, 2018 Introduction - Layered archtecture Networking software is desgined in a layered fashion The bottom layer is the services offered by the underlying

More information

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)

More information

Socket Programming 2007/03/28

Socket Programming 2007/03/28 Socket Programming 2007/03/28 Reference W. Richard Stevens, Unix Network Programming 2/e Volume 1,1998 James F. Kurose and Keith W. Ross, "Computer Networks: A Top-Down Approach Featuring the Internet

More information

Lab 0. Yvan Petillot. Networks - Lab 0 1

Lab 0. Yvan Petillot. Networks - Lab 0 1 Lab 0 Yvan Petillot Networks - Lab 0 1 What You Will Do In This Lab. The purpose of this lab is to help you become familiar with the UNIX/LINUX on the lab network. This means being able to do editing,

More information

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014 Outline Distributed Computing Systems Sockets Socket basics Socket details (TCP and UDP) Socket options Final notes Socket Basics (1 of 2) An end-point for an Internet network connection what application

More information

Topics for this Week

Topics for this Week Topics for this Week Layered Network Architecture ISO/OSI Reference Model Internet Protocol Suite Overview Application Programming Interface BSD Socket API Readings Sections 1.1-1.5, 6.1.3 (socket programming),

More information

CPSC 213. Introduction to Computer Systems. Inter-Process Communication. Unit 2f

CPSC 213. Introduction to Computer Systems. Inter-Process Communication. Unit 2f CPSC 213 Introduction to Computer Systems Unit 2f Inter-Process Communication 1 Reading For Next Three Lectures Textbook The Client Server Programming Model - Web Servers 2nd ed: 11.1-11.5 1st ed: 12.1-12.5

More information

Socket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles

Socket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Note: Java and C# sockets are conceptually quite similar 1 What is a

More information

CSc 450/550 Computer Networks Network Architectures & Client-Server Model

CSc 450/550 Computer Networks Network Architectures & Client-Server Model CSc 450/550 Computer Networks Network Architectures & Client-Server Model Jianping Pan Summer 2007 5/17/07 CSc 450/550 1 Last lectures So far, nuts and bolts views of the Internet Internet evolution and

More information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 August 2017 Announcements Homework 1 will be posted. Will be on website, will announce

More information

System Programming. Sockets

System Programming. Sockets Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introducing 2 3 Internet

More information

ICT 6544 Distributed Systems Lecture 5

ICT 6544 Distributed Systems Lecture 5 ICT 6544 Distributed Systems Lecture 5 Hossen Asiful Mustafa Message Brokers Figure 4-21. The general organization of a message broker in a message-queuing system. IBM s WebSphere Message-Queuing System

More information

JFx Joystick. June 21, Unrestricted Distribution. Revision 1.00

JFx Joystick. June 21, Unrestricted Distribution. Revision 1.00 JFx Joystick TCP Software Interface Revision 1.00 June 21, 2011 Unrestricted Distribution Table of Contents 1 Document Purpose 2 1.1 Conventions 2 2 Software 3 2.1 Startup 3 2.1.1 Initialization 3 2.1.2

More information

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C. Simple TCP Clients and Servers on *nix with C. Aims. This worksheet introduces a simple client and a simple server to experiment with a daytime service. It shows how telnet can be used to test the server.

More information

EECS122 Communications Networks Socket Programming. Jörn Altmann

EECS122 Communications Networks Socket Programming. Jörn Altmann EECS122 Communications Networks Socket Programming Jörn Altmann Questions that will be Addressed During the Lecture What mechanisms are available for a programmer who writes network applications? How to

More information

What s an API? Do we need standardization?

What s an API? Do we need standardization? Network Interface z The network protocol stack is a part of the OS z Need an API to interface applications to the protocol stack. What s an API? Do we need standardization? z The socket interface is the

More information

Ch 7. Network Interface

Ch 7. Network Interface EE414 Embedded Systems Ch 7. Network Interface Part 2/2 Byung Kook Kim School of Electrical Engineering Korea Advanced Institute of Science and Technology Overview 7.1 Advanced Communication Principles

More information

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS Communication Distributed Systems Fall 2002 Communication Process Process Networks and protocols Sockets Remote Invocation Messages Streams 9/10/2001 DoCS 2002 2 Layered Protocols (1) Layers, interfaces,

More information

Socket programming in C

Socket programming in C Socket programming in C Sven Gestegård Robertz September 2017 Abstract A socket is an endpoint of a communication channel or connection, and can be either local or over the network.

More information

Internet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface.

Internet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface. 15-213 Internetworking II: Network programming Berkeley sockets interface Internet protocol stack April 20, 2000 Topics client/server model Berkeley sockets TCP client and server examples UDP client and

More information

Introduction to Network Programming using C/C++

Introduction to Network Programming using C/C++ Introduction to Network Programming using C/C++ Slides mostly prepared by Joerg Ott (TKK) and Olaf Bergmann (Uni Bremen TZI) 1 Would be giving brief introduction on... Parsing Command line Socket Related

More information

Internetworking II: Network programming. April 20, 2000

Internetworking II: Network programming. April 20, 2000 15-213 Internetworking II: Network programming Topics April 20, 2000 client/server model Berkeley sockets TCP client and server examples UDP client and server examples I/O multiplexing with select() Internet

More information

McGraw-Hill The McGraw-Hill Companies, Inc., 2000

McGraw-Hill The McGraw-Hill Companies, Inc., 2000 !! McGraw-Hill The McGraw-Hill Companies, Inc., 2000 "#$% & '$# )1 ) ) )6 ) )* )- ). )0 )1! )11 )1 )1 )16 )1 3'' 4", ( ( $ ( $ $$+, $$, /+ & 23,4 )/+ &4 $ 53" Network Layer Position of network layer Figure

More information

TCP: Three-way handshake

TCP: Three-way handshake Sockets in C 1 Sockets in C The slides by themselves will not be sufficient to learn how to write socket code. If you did not attend class, then you will want to review the relevant chapters in Kerrisk

More information

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition ELEC / COMP 177 Fall 2014 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Project #1 Starts in one week Is your Linux environment all ready? Bring your laptop Work time after quick

More information

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer. Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs

More information

31 ChamSys Remote Protocol Commands

31 ChamSys Remote Protocol Commands 31 ChamSys Remote Protocol Commands ChamSys remote protocol consists of simple commands consisting of a list parameter values separated by commas, and ending in a character A to Z (or a to z). Commands

More information

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably? CSE/EE 461 Lecture 14 Connections Last Time We began on the Transport layer Focus How do we send information reliably? Topics ARQ and sliding windows Application Presentation Session Transport Network

More information

Anatomy of a network. Chapter 3: Network and Communication. Transmission links. Representing data: bits and bytes. Representing data: Frames

Anatomy of a network. Chapter 3: Network and Communication. Transmission links. Representing data: bits and bytes. Representing data: Frames Chapter 3: Network and Communication What is a network? What types of network are there? What networking standards are there? How do you represent information? What is communication protocol? What are

More information

Call DLL from Limnor Applications

Call DLL from Limnor Applications Call DLL from Limnor Applications There is a lot of computer software in the format of dynamic link libraries (DLL). DLLCaller performer allows your applications to call DLL functions directly. Here we

More information