Write a client program to implement simplified http protocol

Assignment Help Computer Networking
Reference no: EM131862512

Assignment: Simplified HTTP on TCP

Submission: (1) Upload all source code (.java) files to both Blackboard and the Virtual Machine, AND (2) set up and test java programs (.class files) on the Virtual Machine.

Part I: Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may choose a port like 5678 and hard code it in both client and server programs. (Hints: for testing both programs on the same computer, you may want to put client program and server program at two different directories. Do NOT hard code the file name "CS3700.htm"!)

• The ending signature of the entity body in the HTTP response message for the case "200 OK":

o When the HTTP Server program sends a HTTP response message out, it pads four continuous blank lines, i.e., "\r\n\r\n\r\n\r\n", to the end of the .htm file as the ending signature of the entity body.

o When the HTTP Client program read the HTTP response message line by line, it counts the number of continuous lines that are empty strings "" (NOT a null string). Once such number reaches 4, the entity body has been fully received.

o It is assumed that the .htm file does not include such ending signature (in the real practice, length of the entity body may be included in the head line and used to determine the end of an entity body).

• HTTP Client Program:

1. Display messages on the standard output to ask the user to input the DNS name/ip of your HTTP server.

2. Buildup the TCP connection to your HTTP server with the Host Name input by User at the given port, and display the RTT of establishing this TCP connection in millisecond (the difference between the moments right before and after creating the socket object). Catch the exception, terminate the program, and display error messages on the standard output if any.

3. Display messages on the standard output to ask the user to input the HTTP method type, name of the htm file requested, HTTP Version, and User-Agent, respectively (separately please!). (hint: all inputs can be strings.)

4. Use the above inputs from user to construct ONE HTTP request message and send it to the HTTP server program over the TCP connection. Your HTTP request message only needs to include the following lines. (Hint: At the end of each line including the last empty line, a "\r\n" is needed. The correctness of the format will be checked by the instructor.):

The request line (hint: the URL should include a ‘/' in front of the htm file name) The header line for the field "Host:"

The header line for the field "User-Agent:"

<empty line>

5. Receive and interpret the HTTP response message from the HTTP Server program line by line, display the RTT (File Transmission Time may be included) of HTTP query in millisecond (the difference between the moment right before HTTP request is sent and the moment right after HTTP response is received) as a single line (e.g., RTT = 1.089 ms), display the status line and header lines of the HTTP response message on the standard output, and save the data in the entity body to a .htm file to local directory if there is any. (Hint: (a) When one empty string "" (NOT a null string!) is read the FIRST TIME, it indicates the header lines are over and the entity body is going to start next line if the case is "200 OK".)

6. Display a message on the standard output to ask the User whether to continue. If yes, repeat steps 3 through 6. Otherwise, close all i/o streams, TCP connection, and terminate the Client program.

• HTTP Server Program:

1. Listen to the given port and wait for a connection request from a HTTP Client.

2. Create a new thread for every incoming TCP connection request from a HTTP client.

3. Read, display to the standard output, and interpret incoming HTTP request message line by line

o If the method given in the request line is NOT "GET", it is a "400 Bad Request" case
o If the file specified in the URL does not exit/cannot be open, it is a "404 Not Found" case
o Otherwise, it is a "200 OK" case

4. According to the case discovered above, construct ONE HTTP response message and send it to the HTTP client program over the TCP connection. Your HTTP response message needs include the following lines using the HTTP message format. (Hint: At the end of each line including those empty lines, a "\r\n" is needed.)

The status line

The header line for the field "Date:"

The header line for the field "Server: ", you may use any value of your choice

<empty line>

Data read from the requested HTML file line by line ... (hint: for the 200 OK case only)

<empty line>
<empty line>
<empty line>
<empty line>

5. Repeat Step 3 through 4 until a null is read.

6. Close all i/o streams and the TCP socket for THIS Client, and terminate the thread for THIS client.

Part II: Test your programs with multiple clients using the Virtual Servers in the cloud.

Reference no: EM131862512

Questions Cloud

What is present value of annuity : A 12-year annuity pays $3,100 per month, and payments are made at the end of each month. What is the present value of the annuity?
Relationship between network diagrams and risk management : In a 2 page (minimum) paper following APA format, answer all of the following questions: Explain the relationship between work breakdown structures (WBS).
What stock price will you get margin call : If your broker requires a 30% maintenance margin, at what stock price will you get a margin call?
Hydrolysis of adenosine triphosphate : Cells use the hydrolysis of adenosine triphosphate, abbreviated as ATP, as a source of energy. Symbolically, this reaction can be represented as
Write a client program to implement simplified http protocol : Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service.
Calculate the energy required to change the temperature : Calculate the energy required to change the temperature of 1.17 kg of ethane (C2H6) from 25.0°C to 70.4°C in a rigid vessel. (Cv for C2H6 is 44.60 J K-1 mol-1.)
Enough to pay bondholders upon maturity : How much will town need to deposit each quarter (so n=4) into savings account with an APR of 2.25% in order to have enough to pay bondholders upon maturity?
Decomposition of nitrous oxide : Concentration vs. time data has been collected for the decomposition of nitrous oxide at 565 °C.
Draw lewis structures for species : Draw Lewis structures for each of the following species. Use expanded octets as necessary.

Reviews

Write a Review

Computer Networking Questions & Answers

  Networking and types of networking

This assignment explains the networking features, different kinds of networks and also how they are arranged.

  National and Global economic environment and ICICI Bank

While working in an economy, it has a separate identity but cannot operate insolently.

  Ssh or openssh server services

Write about SSH or OpenSSH server services discussion questions

  Network simulation

Network simulation on Hierarchical Network Rerouting against wormhole attacks

  Small internet works

Prepare a network simulation

  Solidify the concepts of client/server computing

One-way to solidify the concepts of client/server computing and interprocess communication is to develop the requirements for a computer game which plays "Rock, Paper, Scissors" using these techniques.

  Identify the various costs associated with the deployment

Identify the various costs associated with the deployment, operation and maintenance of a mobile-access system. Identify the benefits to the various categories of user, arising from the addition of a mobile-access facility.

  Describe how the modern view of customer service

Describe how the greater reach of telecommunication networks today affects the security of resources which an organisation provides for its employees and customers.

  Technology in improving the relationship building process

Discuss the role of Technology in improving the relationship building process Do you think that the setting of a PR department may be helpful for the ISP provider? Why?

  Remote access networks and vpns

safekeeping posture of enterprise (venture) wired and wireless LANs (WLANs), steps listed in OWASP, Securing User Services, IPV4 ip address, IPV6 address format, V4 address, VPN, Deploying Voice over IP, Remote Management of Applications and Ser..

  Dns

problems of IPV, DNS server software, TCP SYN attack, Ping of Death, Land attack, Teardrop attack, Smurf attack, Fraggle attack

  Outline the difference between an intranet and an extranet

Outline the difference between an intranet and an extranet A programmer is trying to produce an applet with the display shown in Figure 1 below such that whenever one of the checkboxes is selected the label changes to indicate correctly what has..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd