Sunteți pe pagina 1din 3

CS 742 Computer Communication Networks - Homework 1 - Name:____________ Assigned: Monday, September 8 Due: Monday, September 15 (in class) o Please

show all work on a separate sheet attached to this sheet. (40 points - 5 points for each problem) 1. Imagine that you have trained your St. Bernard, Bernie, to carry a box of three 8mm tapes instead of a flask of brandy. These tapes each contain 7 GBs. The dog can travel at a rate of 18 km/hr. For what range of distances does Bernie have a higher data rate than 150 Mbps? Ans: The dog can carry 21 gigabytes, or 168 gigabits. A speed of 18 km/hour equals 0.005 km/sec. The time to travel distance x km is x / 0.005 = 200x sec, yielding a data rate of 168/200x 2^30 bps or 901.9431322/x Mbps if G is defined as 2^30. For x < 6.01 km, the dog has a higher rate than the communication line. But G is defined as 10^9 in most commercial products. Then the data rate is 168/200x 10^9 bps or 840/x Mbps. For x < 5.6 km, the dog has a higher rate than the communication line. 2. What is the principal difference between connectionless communication and connection-oriented communication? Give an example of unreliable connection-oriented service. Give an example of reliable connectionless service. In which cases unreliable communication is used? Ans: 1) Connectionoriented communication has three phases. In the establishment phase a request is made to set up a connection. Only after this phase has been successfully completed can the data transfer phase be started and data trans ported. Then comes the release phase. Connectionless communication does not have these phases. It just sends the data. 2) Unreliable connection-oriented service: digitized voice Reliable connectionless service: registered mail when the packages can be received as the order sent 3) a. Reliable communication is not available. b. The delay in a reliable service might not be acceptable such as real-time applications. 3. The well-known port numbers are contained in the file /etc/services on most Unix systems. Determine the port number and protocol used by the following servers: a. Mail: b. FTP: c. Time:

Why is it important for all "HTTP" servers to be assigned to the

same port? (5 points) Ans: 1) a. Mail: 25 b. FTP: 21 c. Time: 37 2) A known port will allow all client programs to access the same service through the same port on different machines. 4. Name 7 layers in the OSI Reference Model. Find a protocol for each layer, respectively. Ans: Application layer - FTP, HTTP, SMTP, SSH Presentation layer - ASN.1, NDR, XDR Session layer - WSP Transport layer - UDP, TCP Network layer - IP Datalink layer - HDLC, PPP Physical layer - Ethernet, ISDN 5. List two ways in which the OSI reference model and the TCP/IP reference model are the same. Now list two ways in which they differ. Ans: Both models are based on layered protocols. Both have a network, transport, and application layer. In both models, the transport service can provide a reliable endtoend byte stream. On the other hand, they differ in several ways. The number of layers is different, the TCP/IP does not have session or presentation layers, OSI does not support internetworking, and OSI has both connectionoriented and connectionless service in the network layer. 6. An image is 1024 x 768 pixels with 3 bytes/pixel. Assume the image is uncompressed. How long does it take to transmit it over a 56-kbps modem channel? Over a 1-Mbps cable modem? Over a 10-Mbps Ethernet? Over 100-Mbps Ethernet? Ans: The image is 1024 x 768 x 3 bytes or 2,359,296 bytes. This is 18,874,368 bits. At 56,000 bits/sec, it takes about 337.042 sec. At 1,000,000 bits/sec, it takes about 18.874 sec. At 10,000,000 bits/sec, it takes about 1.887 sec. At 100,000,000 bits/sec, it takes about 0.189 sec. 7. Write a program that reads in an integer, n, and computes the sum of the first n positive integers. Hint: Write a program of the form public class Sum { public static void main(String[] args) { ... System.out.println( ); ... } } Ans: public class Sum { public static void main(String[] args) { int sum = 0; for (int i = Integer.parseInt(args[0]); i > 0; i--)

sum += i; System.out.println("sum = " + sum); } } or import java.io.*; public class Tol { private static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { System.out.print("n = "); int n = Integer.parseInt(stdin.readLine()); int sum = 0; for (int i = 1; i <= n; i++) sum += i; System.out.println("sum = " + sum); } } 8. Use Java to create a BankAccount class. It should contain its constructor, balance, deposit, and withdraw methods. Ans: public class BankAccount { private double balance = 0; BankAccount(double bal) {balance = bal;); public void balance () {return balance;}; public void deposit (double amount) {balance += amount;}; double withdraw (double amount) {balance -= amount;} }

S-ar putea să vă placă și