CS476/576

Assignment #4

Due Midnight, Wednesday   Nov 21, 2007


Write two  C/UNIX sockets programs with the following descriptions:

NAME

TCPdispatch  -   TCP-based Parent dispatches work among children.

UDPdispatch  -   UDP-based Parent dispatches work among children.

 

 

SYNOPSIS

TCPdispatch    <n>   <m>  <InputFile>  <OutputFile>

UDPdispatch    <n>   <m>  <InputFile>  <OutputFile>

 

 

DESCRIPTION

 

This is exactly like Assignment #3   but instead of using Pipes  for the  parent to send data to its children, it uses TCP sockets  for  TCPdispatch and UDP sockets for UDPdispatch.

 

 

Child Process Activities:

 

This is the same as in Assisgnmnet #3, in addition it Logs  a CONNECT record in the ChildrenLog File. The form of this record is: 

 

Ø   For TCP: 

CONNECT:TCP: i:PID:127.0.0.1:ParentPort#   

(e.g., CONNECT:TCP:3:1428:127.0.0.1:57500).

 

Ø   For UDP:  

CONNECT:UDP: i:PID:127.0.0.1:ParentPort#   

(e.g., CONNECT:UDP:1:3452:127.0.0.1:29432).

 

NOTE: After the child’s creation, it sends a UDP message (e.g., “HI”) to its parent. When the parent gets this message, it can then finds out the child’s UDP port number.

 

 

Parent Process Activities:

 

This is the same as in Assisgnmnet #3, in addition it Logs  an ACCEPT record in the ChildrenLog File. The form of this record is: 

 

Ø   For TCP: 

ACCEPT:TCP: i:PID:127.0.0.1:ChildPort#   

(e.g., ACCEPT:TCP:3:1428:127.0.0.1:34562).

 

Ø   For UDP: 

 ACCEPT:UDP: i:PID:127.0.0.1:ChildPort#   

(e.g., CONNECT:UDP:1:3452:127.0.0.1:53463).

 

NOTE: this is logged after the parent receives the child’s “HI” message.

 

The following figure is a general overview of the system:

OutputFile

 

ChildrenLog

 
 

 

 

 

 

 

 

 

 

 

 

 

 


Please see Dr. wahab’s solutions is at:

 

http://www.cs.odu.edu/~cs476/fall07/assignments/a4/wahab/

 

You may use the shell script: check_sh to verify the accuracy of the results.

 

Examples:  they all use InputFile

 

                                                                     

% TCPdispatch 5 5 InputFile OutputFile

 

Results:

 

TCPChildrenLog_5_5

TCPPrent_Log_5_5

TCPcheck_5_5

 

 

% UDPdispatch 5 5 InputFile OutputFile

 

Results:

 

UDPChildrenLog_5_5

UDPPrent_Log_5_5

UDPcheck_5_5