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

Slides:



Advertisements
Similar presentations
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r Sockets are explicitly created, used, released by applications.
Advertisements

Network Programming and Java Sockets
Socket Programming Socket Programming Overview Java Socket Programming
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Application Layer – Lecture.
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
9/23/2003-9/25/2003 Sockets & DNS September 23-25, 2003.
2: Application Layer1 Data Communication and Networks Lecture 12 Java Sockets November 30, 2006.
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
1 Review of Previous Lecture r Electronic Mail r DNS r P2P file sharing.
Internet and Intranet Protocols and Applications Lecture 4: Application Layer 3: Socket Programming February 8, 2005 Arthur Goldberg Computer Science Department.
2: Application Layer1 Chapter 2 (continued) Application Layer – part 2 Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim.
Lecture 11 Java Socket Programming CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger and Joonbok Lee.
Socket programming with UDP and TCP. Socket Programming with TCP Connection oriented – Handshaking procedure Reliable byte-stream.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
1 Network Layers Application Transport Network Data-Link Physical bits.
Protocols Rules for communicating between two entities (e.g., a client and a server) “A protocol definition specifies how distributed system elements interact.
2: Application Layer 1 Socket Programming Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley,
JAVA Socket Programming Joonbok Lee KAIST.
2: Application Layer 1 Socket Programming TCP and UDP.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
ECE5650: Network Programming
1 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
CS 3830 Day 11 Introduction : Application Layer 2 Server-client vs. P2P: example Client upload rate = u, F/u = 1 hour, u s = 10u, d min ≥ u s.
2: Application Layer1 Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross.
Department of Computer and IT Engineering University of Kurdistan Computer Networks II Socket programming By: Dr. Alireza Abdollahpouri.
Chapter 2 Application Layer Computer Networking: A Top Down Approach, 5 th edition. Jim Kurose, Keith Ross Addison-Wesley, April A note on the use.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
Socket Programming Lee, Sooyong
Network Programming and Sockets CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
ICT 6621 : Advanced NetworkingKhaled Mahbub, IICT, BUET, 2008 Lecture 10 TCP/IP Application Layer (2)
Java Socket programming. Socket programming with TCP.
NETWORK PROGRAMMING.
Socket-Programming.  Establish contact (connection).  Exchange information (bi-directional).  Terminate contact.
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
1 CSCD 330 Network Programming Spring 2014 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 7 Application.
Chapter 2 Application Layer Application 2-1. Chapter 2: Application layer 2.1 Principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Inetaddress Class When establishing a connection across the Internet, addresses.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 All rights reserved to Chun-Chuan Yang Upon completion you will be able to: The OSI Model and the TCP/IP Protocol Suite Understand the architecture of.
2: Application Layer1 Network applications: some jargon Process: program running within a host. r within same host, two processes communicate using interprocess.
Topic: Network programming
Socket Programming Socket Programming Overview
Transport layer (last part) Application layer
DNS: Domain Name System
Socket programming with TCP
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
Implementação de Socket UDP e TCP em Java
CSCD 330 Network Programming
Socket Programming Socket Programming Overview
Socket Programming.
CSCD 330 Network Programming
Java Socket Programming
Socket Programming 2: Application Layer.
DNS: Domain Name System
CPSC 441 UDP Socket Programming
Chapter 2: Application layer
DNS: Domain Name System
DNS: Domain Name System
Socket Programming with UDP
Presentation transcript:

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

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

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

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.

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

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

Exercise 1. – Framing Task 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 ) Frame is delimited by starting (AA H i EB H ) and ending (AA H i 7B H ) bytes

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)

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

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| Unframed message (Receiver): |69|-1|-86|-21|-86|123|-1|-109|

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

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

Exercise 3. – Flow Control Task 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: ). The end of communicated is denoted by message KRAJ (75:82:65:74 10 )

Exercise 4. – Datagram Sockets Task 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.

Sample code 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(); } } 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); } } }

Exercise 5. – Stream Sockets Task Description Implement HTTP server and/or client, based on sample Java program code, available on the Web ( ). 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.

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.

Simple Web server (less then 40 lines of code) 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.getInputS tream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputS tream()); requestMessageLine = inFromClient.readLine(); StringTokenizer tokenizedLine = new StringTokenizer(requestMessageLine); if (tokenizedLine.nextToken().equals("GET")){ fileName = tokenizedLine.nextToken(); if (fileName.startsWith("/") == true ) fileName = fileName.substring(1); 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/ Document Follows\r\n"); if (fileName.endsWith(".jpg")) outToClient.writeBytes("Co ntent-Type: image/jpeg\r\n"); if (fileName.endsWith(".gif")) outToClient.writeBytes("Co ntent-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"); } }

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

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.