1 / 20

Lab assignments in Computer Networks at Faculty of Electronic Engineering - Nis

Lab assignments in Computer Networks at Faculty of Electronic Engineering - Nis. Introduction. One semester course (VIII) Hours per week: 2+2+1 Textbooks: Andrew S. Tanenbaum, Computer Networks James F. Kurose, Keith W. Ross, Computer Networking: A Top Down Approach Featuring the Internet.

zurina
Download Presentation

Lab assignments in Computer Networks at Faculty of Electronic Engineering - Nis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab assignments in Computer Networks at Faculty of Electronic Engineering - Nis

  2. Introduction • One semester course (VIII) • Hours per week: 2+2+1 • Textbooks: • Andrew S. Tanenbaum, Computer Networks • James F. Kurose, Keith W. Ross, Computer Networking: A Top Down Approach Featuring the Internet

  3. Main problemsof students population Not interested in Exams “dragged” from previous semesters Not attended classes Often exams Fear of new matter and programming language Prerequisite exams not passed

  4. Ways to solve the problem • Avoid difficult exercises. • Include new and popular technologies and programming languages. • Enable accommodation period, and new programming language adoption, at the start. • Combine several problems in one exercise. • Purpose of exercise should be obvious, and easily applicable.

  5. Goals • Introduction to Java application programming • Introduction to data-link layer functions • Introduction to Java Socket programming • Introduction to common network utilities available on WinNT/2000 platforms

  6. Exercises • Framing • Error Control • Flow Control – Stop-and-wait • Datagram Sockets – Stop-and-wait chatter • Stream Sockets – HTTP Server/Client • Windows NT/2000 Net Services

  7. Exercise 1. – FramingTask Description • Implement Java class (DataLinkLayer) for message framing. The class have to implement, at least two methods: • frame – for message framing, and • unframe – for message extraction • Maximal frame size is 128 B. • Sending and receiving should be performed using PhysicalLayer class methods: • void send (byte[] data) and • byte[] receive() metode. (class PhysicalLayer is already created and is available for download from http://gislab.elfac.ni.ac.yu/Aks/Download/PhysicalLayer.class) Frame is delimited by starting (AAH i EBH) and ending (AAH i 7BH) bytes

  8. Java Classes to Implement • Sender – sends message to DataLink Layer • Receiver – receives message from DataLink Layer and displays on the screen • DataLinkLayer – main class that implements two methods: • public byte[] frame (byte[] data) • public byte[] unframe(byte[] data)

  9. Exercise 1. – FramingExample 45:3E:AA:EB:AA:7B:67:93H Framing bytes Framing bytes AA:EB:45:3E:AA AA:EB:AA AA:7B:67:93:AA:7BH Inserted bytes Inserted bytes 45:3E:AA:EB:AA:7B:67:93H

  10. Example of Screen Layout Original message (Sender): |69|-1|-86|-21|-86|123|-1|-109| Framed message in communication channel (Sender’s output): |0|0|0|-86|-21|69|-1|-86|-86|-21|-86|-86|123|-1|-109|-86|123|0| |0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| |0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| Unframed message (Receiver): |69|-1|-86|-21|-86|123|-1|-109|

  11. Exercise 2. – Error ControlTask Description Modify the DataLinkLayer class by adding iCheckSum method for error control. Error control should be performed by calculating Internet checksum.

  12. Example of Screen Layout Original message (Sender): |69|-1|-86|-21|-86|123|-1|-109| Framed message in communication channel (Sender’s output): |0|0|0|-86|-21|69|-1|-86|-86|-21|-86|-86|123|-1|-109|23|14| 86|123|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| |0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| Unframed message (Receiver): |69|-1|-86|-21|-86|123|-1|-109| -> No error

  13. Exercise 3. – Flow ControlTask Description • Modify the DataLinkLayer class from exercise 2, by adding flow control capability, based on stop and wait protocol. • For noisy channel simulation class NoisyPhysicalLayer can be used (and downloaded from: http://gislab.elfak.ni.ac.yu/Aks/Download/NoisyPhysicalLayer.class). • The end of communicated is denoted by message KRAJ (75:82:65:7410)

  14. Exercise 4. – Datagram SocketsTask Description • Implement simple chatter application ( both client and server side ), using stop and wait protocol for flow control. • Application could be based on sample Java program code, available on the Web.

  15. Sample code import java.io.*;import java.net.*;class UDPServer {  public static void main(String args[]) throws Exception    {       DatagramSocket serverSocket = new DatagramSocket(9876);      byte[] receiveData = new byte[1024];      byte[] sendData  = new byte[1024];      while(true)        {          DatagramPacket receivePacket =             new DatagramPacket(receiveData, receiveData.length);          serverSocket.receive(receivePacket);          String sentence = new String(receivePacket.getData());          InetAddress IPAddress = receivePacket.getAddress();          int port = receivePacket.getPort();String capitalizedSentence = sentence.toUpperCase();           sendData = capitalizedSentence.getBytes();          DatagramPacket sendPacket =             new DatagramPacket(sendData, sendData.length, IPAddress,                               port);          serverSocket.send(sendPacket);        }    }} import java.io.*;import java.net.*;class UDPClient {    public static void main(String args[]) throws Exception    {     BufferedReader inFromUser =        new BufferedReader(new InputStreamReader(System.in));      DatagramSocket clientSocket = new DatagramSocket();      InetAddress IPAddress = InetAddress.getByName("hostname");      byte[] sendData = new byte[1024];      byte[] receiveData = new byte[1024];      String sentence = inFromUser.readLine();      sendData = sentence.getBytes();       DatagramPacket sendPacket =new DatagramPacket(sendData, sendData.length, IPAddress, 9876);clientSocket.send(sendPacket);      DatagramPacket receivePacket =         new DatagramPacket(receiveData, receiveData.length);clientSocket.receive(receivePacket);      String modifiedSentence =          new String(receivePacket.getData());      System.out.println("FROM SERVER:" + modifiedSentence);       clientSocket.close();    }}

  16. Exercise 5. – Stream SocketsTask Description • Implement HTTP server and/or client, based on sample Java program code, available on the Web (http://gislab.elfak.ni.ac.yu/Aks/Download/HTTPServer.java). • The server should be able to return following codes: • 200 OK • 400 Bad Request • 404 Not Found • 505 HTTP Version Not Supported • The client should print, at least, header of received HTTP message.

  17. Validation • Server implementation should be validated by InternetExplorer Web client (requiring some image, for example, from the server) • Client implementation should be validated by visiting some real Web sites.

  18. Simple Web server(less then 40 lines of code) import java.io.*;File file = new File(fileName);          int numOfBytes = (int) file.length();           FileInputStream inFile  = new FileInputStream (fileName); byte[] fileInBytes = new byte[numOfBytes];          inFile.read(fileInBytes);           outToClient.writeBytes("HTTP/1.0 200 Document Follows\r\n");           if (fileName.endsWith(".jpg"))                  outToClient.writeBytes("Content-Type: image/jpeg\r\n");          if (fileName.endsWith(".gif"))                  outToClient.writeBytes("Content-Type: image/gif\r\n");           outToClient.writeBytes("Content-Length: " + numOfBytes + "\r\n");          outToClient.writeBytes("\r\n");           outToClient.write(fileInBytes, 0, numOfBytes);           connectionSocket.close();}      else System.out.println("Bad Request Message");     }} import java.io.*;import java.net.*;import java.util.*; class WebServer{     public static void main(String argv[]) throws Exception  {           String requestMessageLine;          String fileName;           ServerSocket listenSocket = new ServerSocket(6789);          Socket connectionSocket = listenSocket.accept();           BufferedReader inFromClient =            new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));          DataOutputStream outToClient =            new DataOutputStream(connectionSocket.getOutputStream());           requestMessageLine = inFromClient.readLine();           StringTokenizer tokenizedLine =            new StringTokenizer(requestMessageLine); if (tokenizedLine.nextToken().equals("GET")){           fileName = tokenizedLine.nextToken();           if (fileName.startsWith("/") == true )                         fileName  = fileName.substring(1);

  19. Exercise 6. – Command Promt WinNT/2000 Net Utilities Introduction to real TCP/IP protocols using the following services: • Arp • IPConfig • Netstat • Ping • Route • Tracert

  20. Conclusion • Computer Networks is a very dynamic topic, so this is only the current “state of art”. • Laboratory exercise should be under constant changing, following the students needs and capabilities, on one side, and main streams and new technologies, on the other.

More Related