Presentation is loading. Please wait.

Presentation is loading. Please wait.

DMET 602: Networks and Media Lab

Similar presentations


Presentation on theme: "DMET 602: Networks and Media Lab"— Presentation transcript:

1 DMET 602: Networks and Media Lab
Amr El Mougy Yasmeen Essam Hana Medhat Mariam Samy

2 Old Format Total of 8 experiments
Each week the lecture explains the theoretical concepts A quiz is given at the end of each lecture The following the experiment is conducted in the lab Students answer oral questions and submit a report

3 New Format Week Lectures Tutorials 1 Socket Programming Fundamentals
(One Quiz) 2 One Client, One Server Many Clients, One Server (multi-threading) Many Clients, Many Servers Project Evaluation 3 4 5 Web Applications Fundamentals (Two Quizzes) 6 Basics of Web servers HTTP Requests Sessions Security Certificates 7 8 9 Multicasting (Quiz) 10 QoS (Quiz) Multicasting Experiment 11 Mobile IP (Quiz) QoS Experiment 12 Mobile IP Experiment

4 Regulations: In the Lab
Cross-attendance is not allowed If you have a critical reason that prevents you from attending the lab you have to inform your TA before your slot. If your excuse is accepted you will be assigned to a different slot. If you don’t inform the TA before your slot, you get an F in the experiment and your attendance will not be counted No compensation is offered to any student who will miss his lab for any reason (except a force majeure) and no switching between slots is allowed. Arriving more than 15 mins late to a lab slot earns you an F and your attendance will not be counted In case your lab time happens to be OFF for an official holiday, assume that you did the experiment and proceed with the rest of the schedule normally, you will be compensated at the end of the term

5 Grading Scheme Quizzes are best 5/6
In-lab Tasks/Oral Questions are divided evenly between the three course parts (11% for the tasks in socket programming, 11% for the tasks in web applications, 11% for all experiments combined) Same division goes for the project evaluation/lab report

6 Networking Crash Course

7 Encapsulation destination source application transport network link
message M application transport network link physical segment Ht M Ht datagram Ht Hn M Hn frame Ht Hn Hl M link physical switch destination network link physical Ht Hn M Ht Hn Hl M M application transport network link physical Ht Hn M Ht M Ht Hn M router Ht Hn Hl M Introduction

8 Transport services and protocols
provide logical communication between app processes running on different hosts transport protocols run in end systems send side: breaks app messages into segments, passes to network layer rcv side: reassembles segments into messages, passes to app layer more than one transport protocol available to apps Internet: TCP and UDP application transport network data link physical logical end-end transport application transport network data link physical Transport Layer

9 Internet transport-layer protocols
reliable, in-order delivery (TCP) congestion control flow control connection setup unreliable, unordered delivery: UDP no-frills extension of “best- effort” IP services not available: delay guarantees bandwidth guarantees application transport network data link physical network data link physical network data link physical logical end-end transport network data link physical network data link physical network data link physical network data link physical application transport network data link physical

10 Developing an Internet App
Application programmer Doesn’t need to send IP packets Doesn’t need to send Ethernet frames Doesn’t need to know how TCP implements reliability Only need a way to pass the data down Socket is the API to access transport layer functions

11 What the Lower Layer Needs
We pass the data down. What else does the lower layer need to know? How to identify the destination process? Where to send the data? (Addressing) What process gets the data when it is there? (Multiplexing)

12 Sockets An interface between application and network
The application creates a socket The socket type dictates the style of communication reliable vs. best effort connection-oriented vs. connectionless Once configured the application can pass data to the socket for network transmission receive data from the socket (transmitted through the network by some other host)

13 Multiplexing/demultiplexing
Demultiplexing at rcv host: Multiplexing at send host: delivering received segments to correct socket gathering data from multiple sockets, enveloping data with header (later used for demultiplexing) = socket = process application application application P3 P1 P2 P4 P1 transport transport transport network network network link link link physical physical physical host 3 host 1 host 2 Transport Layer

14 Identifying the Destination
Addressing IP address hostname (resolve to IP address via DNS) Multiplexing port Server socket address :80 Client socket address :3479 FTP Server (port 21) Client HTTP Server (port 80) Connection socket pair ( :3479, :80) Client host address Server host address

15 Choosing Port Numbers UDP TCP
Source port: 26145 Dest. port: 80 Src IP: C Dest. IP: B UDP TCP Source port: 19157 Dest. port: 46428 Source port: 7532 Dest. port: 80 Src IP: C Dest. IP: B Source port: 46428 Dest. port: 19157 Source port: 26145 Dest. port: 80 Src IP: A Dest. IP: B Server is always listening on the well-known port number Client chooses a source port number and inserts it in the header. The destination port number is the well- known port number In the reply, the server inserts the port number received in the packet in the destination port number Server is always listening on the well-known port number Client chooses a source port number and inserts it in the header. The destination port number is the well-known port number The server creates a socket for the client that is identifiable via the combination of src IP and src port address

16 Socket Programming Goal: learn how to build client/server application that communicate using sockets Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm two types of transport service via socket API: unreliable datagram reliable, byte stream-oriented a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket

17 Socket Programming with TCP
Client must contact server server process must first be running server must have created socket (door) that welcomes client’s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers used to distinguish clients application viewpoint TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server

18 Socket Programming with TCP
Example client-server app: 1) client reads line from standard input (inFromUser stream) , sends to server via socket (outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket (inFromServer stream) Client process client TCP socket

19 Client/Server Socket Interaction
Server (running on hostid) Client create socket, port=x, for incoming request: welcomeSocket = ServerSocket() TCP connection setup close connectionSocket read reply from clientSocket create socket, connect to hostid, port=x clientSocket = Socket() wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to

20 Example: Java Client import java.io.*; import java.net.*;
class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); Create input stream Create client socket, connect to server Create output stream attached to socket

21 Example: Java Client (Cont’d)
Create input stream attached to socket BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } Send line to server Read line from server

22 Example: Java Server Create welcoming socket at port 6789
import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket

23 Example: Java Server (Cont’d)
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } Create output stream, attached to socket Read in line from socket Write out line to socket End of while loop, loop back and wait for another client connection

24 Project Description Chatting application using TCP socket programming
Multiple clients, two servers Clients are associated with a particular server Messages should be sent from any client to any client The project should have a GUI that implements all required features

25 Client Functionalities
1. Join(name): The client uses this message to log on to the server (i.e., initiate a chat session).The client must send this message first, before sending any other messages. The member name is any name the client chooses to be identified by. 2. GetMemberList(): This message asks for a list of all members on the network. 3. Chat (Source, Destination, TTL, Message): The chat message that the user will send to another user. Any chat message consists of three header fields and a body:  - Source: The id of the sender. - Destination: The id of the receiver. - Time To Live (TTL): TTL is a counter which is decremented at each chat server, when it reaches zero the message should be discarded and an error message should be sent to the sender. The purpose of TTL is to prevent the message from looping infinitely in the network. The default value for the TTL is set to 2. 4. Quit: This message is used to log off.

26 Server Functionalities
1. JoinResponse: This is the response to the join request of the client whether accepted or not. (Note: the client is only rejected when he registers with a used name). 2. MemberListResponse: This sends the list of all members to the client upon request. 3. Route (Message, Destination): This method sends the message to the targeted destination. The server should check whether the destination is directly connected to it or not. In the case where the destination is directly connected to it, then it will directly forward the message. However if the destination is not found in the list of clients connected to the server, then it will send the message to the other chat server.


Download ppt "DMET 602: Networks and Media Lab"

Similar presentations


Ads by Google