TDC 368: Unix and Network Programming, winter 09

 


Assignment 4-5: Proxy Server

 


Due: 11:59pm Friday, 10 March 2009

 

 


Assignment Description

Develop a TCP proxy program that acts as a client and a server. It receives packet from Echo clients and forwards them to an Echo server and vice versa.

 

 

A. Iterative Proxy Server

 

Write an iterative socket program that performs a proxy services as follows:

 

  • A proxy program creates two TCP sockets: a server socket (SC) and a client socket (CS).
  • The client socket is connected to an Echo server
  • When Proxy receives a message from Echo client through SC after accepting the connection, it forwards this message directly to Echo server through the CS.
  • Similarly, the Proxy forwards all responses (messages) from the CS to the client connected in the server socket.
  • This will continue until the client closes the connection with Proxy. Then Proxy goes back to accept new connections and receive messages similarly.

 

B. Concurrent Proxy Server

 

Write a concurrent socket program that performs a proxy services as follows:

 

  • A proxy that creates a TCP server socket and after accepting a new connection from a echo client, it forks a child (PC) to serve this client. The PC inherits from the parent the active socket (SC) connected to the echo client.
  • The child program creates a client socket (CS) and then it connects to an Echo server
  • When PC receives a message from Echo client through SC after accepting the connection, it forwards this message directly to Echo server through the CS.
  • Similarly, the PC forwards all responses (messages) from the CS to the client connected in the server socket.
  • This will continue until the client closes the connection with PC. Then PC will exit.
  • The parent always goes back to accept a new connection and never communicates with the Echo clients or servers.

 

 

 

You can run the proxy server as follows:

 

Proxy [pport] [sport]

 

Where pport and sport are the port numbers at which the proxy and echo servers listening at respectively. In other words, the echo client connect to pport (of the proxy) and the proxy server connects to sport (of echo server).

 

NOTE: The Echo client and server code is in ~ealshaer/public/TDC368/ComersSrc.  Copy all files to your directory and use the Makefile to compile the proxy, Echo server and Echo client programs.

 

 

Submission Procedure:

Write your name and SSN in the main program and in the README file. After cleaning your directory from objects and bin files, do the following: (Your submission must contain a Makefile and a README file that describes how to run your program). You must use the same naming convention and command line arguments as specified in the assignment description.

 

$ tar -cvf  <MNLABLogin>-<SSNLast4>-hw4-5.tar  *

$gzip  <MNLABLogin>-<SSNLast4>-hw4-5.tar

 

DO NOT for get to take out any binary or object files in your submission

 

Submit the zipped file to DLWEB.

 

Grading Policy

NO LATE ASSIGNEMT WILL BE GRADED.