Recitation 12: ProxyLab Part 1

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications.
Programming project #4 1 CS502 Spring 2006 Programming Project #4 Web Server CS-502 Operating Systems Spring 2006.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
Carnegie Mellon 1 Proxy Web & Concurrency Ian Hartwig 15/ Section E Recitation 13 April 15 th, 2013.
 Proxy Servers are software that act as intermediaries between client and servers on the Internet.  They help users on private networks get information.
FIREWALL TECHNOLOGIES Tahani al jehani. Firewall benefits  A firewall functions as a choke point – all traffic in and out must pass through this single.
Lecturer : Ms.Trần Thị Ngọc Hoa Chapter 8 File Transfer Protocol – Simple Mail Transfer Protocol.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
FTP (File Transfer Protocol) & Telnet
Computer Systems II CSC 2405 Network Programming.
CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Operating Systems Recitation 9, May 19-20, Iterative server Handle one connection request at a time. Connection requests stored in queue associated.
Fundamentals of Proxying. Proxy Server Fundamentals  Proxy simply means acting on someone other’s behalf  A Proxy acts on behalf of the client or user.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
LinuxChix Apache. Serving Webpages The layer 7 protocol (HTTP) is what our browsers talk to get us the websites we can't seem to live without. HTTP is.
Socket Programming Lab 1 1CS Computer Networks.
Carnegie Mellon 1 Proxy: Web & Concurrency : Introduction to Computer Systems Recitation 13: Monday, Nov. 18 th, 2013 Marjorie Carlson Section A.
Programming with UDP – II Covered Subjects: Creating UDP sockets Client Server Sending data Receiving data Connected mode.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
4343 X2 – Outline The Domain Name System The Web.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
Internet Flow By: Terry Hernandez. Getting from the customers computer onto the internet Internet Browser
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Bapi Chatterjee Prajith R G.
Overview on Web Caching COSC 513 Class Presentation Instructor: Prof. M. Anvari Student name: Wei Wei ID:
Java Networking I IS Outline  Quiz #3  Network architecture  Protocols  Sockets  Server Sockets  Multi-threaded Servers.
1 Network Communications A Brief Introduction. 2 Network Communications.
Carnegie Mellon Recitation 11: ProxyLab Fall 2009 November 16, 2009 Including Material from Previous Semesters' Recitations.
What’s Really Happening
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Aras Atalar Prajith R G.
Block 5: An application layer protocol: HTTP
WWW and HTTP King Fahd University of Petroleum & Minerals
Hypertext Transfer Protocol
HTTP – An overview.
Computing with C# and the .NET Framework
Hypertext Transport Protocol
Extending echo server HTTP Broken pipe error Feedback and evaluation
Networks Problem Set 3 Due Oct 29 Bonus Date Oct 26
Web Caching? Web Caching:.
Networks and Client/Server Applications
CH5 TCP Client - Server Example:
Topic 5: Communication and the Internet
The Internet and HTTP and DNS Examples
UNIX Sockets Outline Homework #1 posted by end of day
Recitation 14: Proxy Lab Part 2
HTTP Hypertext Transfer Protocol
Recitation 12: ProxyLab Part 1
HTTP and Sockets Lecture 6
Recitation 14: Proxy Lab Part 2
Network Programming: Part II CSCI 380: Operating Systems Lecture #13
Data Communication EDA344, DIT420 Description of Lab 1 and Optional Programming HTTP Assignment Aras Atalar Prajith R G 24/01/2018.
Lecture 3: Secure Network Architecture
Server-side Programming CSE 333 Autumn 2018
Server-side Programming CSE 333 Summer 2018
Network Programming: Part II CSCI 380: Operating Systems
Server-side Programming CSE 333 Winter 2019
Chapter 5 멀티스레드 u-Network Design Lab 4.
HTTP Hypertext Transfer Protocol
Web Server Design Week 6 Old Dominion University
Web Server Design Week 7 Old Dominion University
Web Server Design Week 7 Old Dominion University
Presentation transcript:

Recitation 12: ProxyLab Part 1 Instructor: TA(s)

Outline Proxies Networking Networking Demos

Proxy Lab There are no grace days / late submissions 8% of final grade You are submitting an entire project Modify the makefile Split source file into separate pieces Submit regularly to verify proxy builds on Autolab Your proxy is a server, it should not crash!

Why Proxies? Proxies are both clients and servers Can perform useful functions as requests and responses pass by Examples: Caching, logging, anonymization, filtering, transcoding Client A Request foo.html foo.html Request foo.html Origin Server Proxy cache foo.html Request foo.html Client B foo.html

Echo Server + Client Structure Client Server 2. Start client 1. Start server Client Server open_clientfd open_listenfd Echo Server + Client Structure Connection request Await connection request from client accept 3. Exchange data fgets rio_writen rio_readlineb Client / Server Session rio_readlineb fputs rio_writen 4. Disconnect client EOF close 5. Drop client rio_readlineb close

Transferring HTTP Data If something requests a file from a web server, how does it know that the transfer is complete? A) It reads a NULL byte. B) The connection closes. C) It reads a blank line. D) The HTTP header specifies the number of bytes to receive. E) The reading function receives EOF. Answer is D. A blank line separate the response header from the rest of the response, which can be binary data full of null bytes or line feed characters. Normally in HTTP/1.0 the connection is closed after, so the client would indeed see EOF. The connection can close for other reasons though, and one can’t tell if this was due to an abnormal cause unless the response length is specified.

Telnet Demo Telnet is valuable for manually testing your proxy What are valid requests to web servers? What do valid replies look like? Connect to a shark machine $ telnet www.cs.cmu.edu 80 GET /~213/recitations/rec12.html HTTP/1.0 <press enter> <press enter>

Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output?

Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output? (Sample output:) $ ./echoserver 10101 Accepted connection from hammerheadshark.ics.cs.cmu.edu:46422 hammerheadshark.ics.cs.cmu.edu:46422 sent 6 bytes Disconnected from hammerheadshark.ics.cs.cmu.edu:46422

Echo Demo See the instructions written in the telnet results to set up the echo server. Get someone nearby to connect using the echo client. What does echoserver output? (Sample output:) $ ./echoserver 10101 Accepted connection from hammerheadshark.ics.cs.cmu.edu:46422 hammerheadshark.ics.cs.cmu.edu:46422 sent 6 bytes Disconnected from hammerheadshark.ics.cs.cmu.edu:46422 Server listening port Client port Client host

Echo Demo Look at echoclient.c Opens a connection to the server Reads/writes from the server Look at echoserver output Why is the printed client port different from the server’s listening port?

Echo Demo Look at echoclient.c Opens a connection to the server Reads/writes from the server Look at echoserver output Why is the printed client port different from the server’s listening port? Server opens one “listening” port Incoming clients connect to this port Once server accepts a connection, it talks to client on a different “ephemeral” port Listening port Client connects to server Ephemeral port GET /~213/recitations/rec12.html HTTP/1.0 HTTP/1.1 200 OK Content-Type: text/html…

Echo Demo Try to connect two clients to the same server. What happens?

Echo Demo Try to connect two clients to the same server. What happens? Second client has to wait for first client to finish! Server doesn’t even accept second client’s connection Where/why are we getting stuck?

Echo Demo Try to connect two clients to the same server. What happens? Second client has to wait for first client to finish! Server doesn’t even accept second client’s connection Where/why are we getting stuck? Because we’re stuck in echo() talking to the first client, echoserver can’t handle any more clients Solution: multi-threading

Echo Server Multithreaded How might we make this server multithreaded? (Don’t look at echoserver_t.c) while (1) { // Allocate space on the stack for client info client_info client_data; client_info *client = &client_data; // Initialize the length of the address client->addrlen = sizeof(client->addr); // Accept() will block until a client connects to the port client->connfd = Accept(listenfd, (SA *) &client->addr, &client->addrlen); // Connection is established; echo to client echo(client); }

Echo Server Multithreaded View the code in echoserver_t.c Nominate one student in class to run the echoserver_t Have several others connect to it

Echo Server Multithreaded echoserver_t.c isn’t too different from echoserver.c To see the changes: `diff echoserver.c echoserver_t.c` Making your proxy multithreaded will be very similar However, don’t underestimate the difficulty of addressing race conditions between threads! Definitely the hardest part of proxylab More on this next time...

Reminders Read the writeup Start early Remember, no late submissions Come to office hours this week, before it gets crowded! Work incrementally and take breaks