CSIS0234A Computer and Communication Networks

Mar 2, 2007 - The purpose of this exercise is to let you familiar with socket programming in C. Write a file transfer application that runs over UDP. Assume the ...
143KB taille 4 téléchargements 383 vues
CSIS0234A Computer and Communication Networks Assignment One (8%) Due date: 5:00pm Mar 2, 2007 Part One - Socket Programming (60%) The purpose of this exercise is to let you familiar with socket programming in C. Write a file transfer application that runs over UDP. Assume the transfer occurs over a local area network so reliable transfer is not a concern. Assume also that UDP will accept at most 500 bytes/datagram. Implement a server that opens a socket and listens for incoming data at a particular port number. Implement a client that reads a file from the file system and transfers the file to the server. When the server receives the client’s data, it writes this data to a file. Include a means for the client to indicate the end of transmission.

Computer Platform to use The program should be structured in a way that it can be compiled successfully under Linux, Solaris, and Windows (similar to the one given in Part D of Tutorial One). In other words, you are expected to design a portable program that can be used to transfer any file between two different platforms. For example, a Linux machine to a Windows machine, or vice versa. Client Program You should implement a client program, named client.c. Its command line input should be as follows: cl i e n t The client program should be able to read data from a file specified and send it to the server via a UDP socket. The client should let the server know when the end of transmission is. When the transferring file has a size greater than 500 bytes, it can not fit within one datagram as the maximum size is 500 bytes. In this case, the file should be split into fragments with maximum size of 500 and is sent to the server one by one. This can be done by iteratively reading 500 bytes at a time and sending it to the server until all data has been read and sent.

Note: The local network is quite reliable. However, the receiving machine may encounter buffer overflow if the sender is sending the datagrams too fast. To avoid having data loss due to buffer overflow, we suggest you to slow down your transmission by adding a sleep() between consecutive datagram transmissions. Or, you can invent other means to regulate the transmission. Server Program You should implement a server program, named server.c. Its command input should be as follows: ser v e r



[ ]

where is optional The server should open a UDP socket and listen at a specified port number. It should also create and open a file with the specified name from [name of file to be created] or the original name of the file sent by client. Then the server should write the data received from client to the opened file. The server should close the UDP connection as well as the file handler at the end of transmission. Examples of Execution Suppose you have to send a file named client-file.jpg from belief.cs.hku.hk to genius.cs.hku.hk. • At genius.cs.hku.hk, type ./server 55667 OR ./server 55667 received-file.jpg •

At belief.cs.hku.hk, type ./client genius 55667 client-file.jpg

What to submit and how? 1) The program source code with in-line documentation 2 ) A readme file that describes how your program works and any special features that you have included in your program. You should hand-in item1 & 2 by web-handin program. Marking policy Criteria Mark The portability issue of the source code across different OSes. 2/10 The correctness of the programs – the FTP application can successfully transfer a file (binary or text) (large or small) from the ftp client to the ftp 7/10 server across different platforms, e.g. transfer a pdf file from Windows platform to Linux platform. The quality of the documentation. 1/10 Total 10/10

Part Two – Short Questions (40%) Please hand-in the written assignment to the course assignment box (B2). Q1 - Suppose we wish to transmit at a rate of 64 kbps over a 3 kHz telephone channel. What is the minimum SNR (in dB) required to accomplish this? Q2 – The following diagram shows a network graph with 6 networking devices interconnected by some means. The label on each link represents the “cost” of using that link to carry data. List four routes through which A can communicate with F. How many are there all together? (Assume a route does not pass through a node more than once.) Which route is the cheapest one for A to communicate with F?

Q3 – A client-server system uses a satellite network, with the satellite at a height of 45,000 km. What is the best-case delay in response to a request? Q4 – When a file is transferred between two computers, two acknowledgment strategies are possible. In the first one, the file is chopped up into packets, which are individually acknowledged by the receiver, but the file transfer as a whole is not acknowledged. In the second one, the packets are not acknowledged individually, but the entire file is acknowledged when it arrives. Discuss these two approaches when the file transfer is happened (i) across Internet (ii) on a direct point-to-point link between the two machines. Q5 – Suppose that a certain communication protocol involves a per-packet overhead of 100 bytes for headers and framing. We send 1 million bytes of data using this protocol. However, one data byte is corrupted and the entire packet containing it is thus lost. Assume no data recovery or retransmission. Calculate the total number of overhead + loss bytes for packet data sizes (payload) of 1000, 5000, 10000, and 20000 bytes. Which size is optimal? Q6 – Draw the digital signals for the bit string 001010001011 using each of the NRZ, NRZI, Manchester, differential Manchester, and 4B5B digital encoding techniques. Assume the signal is “high” prior to receipt of the first bit. Q7 – Suppose you want to transmit the data 100111001 and the generator polynomial is x6 + x3 + 1. What bit string is actually sent? Q8 – Suppose a transmission channel operates at 3 Mbps and that it has a bit error rate of 103 . Bit errors occur at random and independent of each other. Suppose that the following code is used. To transmit a 1, the codeword 111 is sent; to transmit a 0, the codeword 000 is sent. The receiver takes the three received bits and decides which bit was sent by taking the majority vote of the three bits. Find the probability that the receiver makes a decoding error.