CS 779/879 Design of Network Protocols Spring 2009 Second Exam Time 2 & 1/2 hours Open Book Name: Login: All questions are of equal weights. Question 1: The following functions can be used to read from or write to a socket S: read recv recvfrom recvmsg write send sendto sendmsg Specify which of the preceding functions can be used with S if the type of S is: T: TCP U: UDP Uc: Connected UDP S: SCTP S Q: SCTP Q Qc: Connected SCTP Q You may answer this question by entering Yes or No in the following table: T read recv recvfrom recvmsg write send sendto sendmsg U Uc S Q Qc Question 2: Consider the following set of SCTP Daytime Servers and Clients: S4S: Server IPv4 Stream: DayTimeServer4SctpS S6S: Server IPv6 Stream: DayTimeServer6SctpS C4S: Client IPv4 Stream: DayTimeClient4SctpS C6S: Client IPv6 Stream: DayTimeClient6SctpS S4Q: Server IPv4 Sequence Packet: DayTimeServer4SctpQ S6Q: Server IPv6 Sequence Packet: DayTimeServer6SctpQ C4Q: Client IPv4 Sequence Packet: DayTimeClient4SctpQ C6Q: Client IPv6 Sequence Packet: DayTimeClient6SctpQ Each client has to specify the IP address of the server. The IP address of the server may be specified using one or more of the following 3 format: 4: IPv4 address format, e.g., IPv4: 128.82.4.210 or 6: IPv6 address format: fe80::203:baff:fe2a:67ff or m: IPv4-mapped IPv6 address, e.g., ::ffff:128.82.4.210 Use the above symbols (4, 6 or m) to fill in each entry in the following Table with ALL possible correct address formats that can be used by a client to interact with its corresponding server: C4S S4S S6S S4Q S6Q C6S C4Q C6Q Question 3: The following udp client that sends a question to a udp server and then display the returned answer: main(int argc, char **argv) { int sendsock; struct sockaddr_in dest; struct sockaddr_in cliaddr; int len; char Answer[1024]; char *Question; sendsock = socket(PF_INET,SOCK_DGRAM, 0); dest.sin_family = AF_INET; dest.sin_addr.s_addr = inet_addr(argv[1]); dest.sin_port = htons(atoi(argv[2])); Question = argv[3]; sendto(sendsock, Question, strlen(Question), 0, (SA*)&dest, sizeof(dest)); len = sizeof(cliaddr); recvfrom (sendsock, Answer, sizeof(Answer), 0, (SA *) &cliaddr, &len); printf("%s\n", Answer); } Note that if there is no server running at the specified host and port then the client hangs forever. To solve this problem we may: 1. Use the concept of connected client. 2. Use the select or poll 3. Use the Alarm signal. Modify this program to use any one of these three techniques. Question 4: Explain how it is possible to write a server that uses one port and can handle the requests from any client that uses any of the following transport protocol types: tcp, udp, sctp and any IP protocol type: ipv4, ipv6 Question 5: Describe how an sctp program can: 1. Send a message on a specific stream? 2. Determine which stream a message is received?