Skip to content

Commit f84423b

Browse files
readme updated for P4 P5 P6
1 parent d6ba5d7 commit f84423b

File tree

3 files changed

+58
-11
lines changed

3 files changed

+58
-11
lines changed

P4/readme.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
# P1 RTT
1+
# P4 RTT
2+
3+
This exercise develops a program which reads a text file with one IP(v4/v6) address per line and calculates RTT values of these IPs and prints them in a line. This exercise made use of raw sockets and ICMP ECHO messages to calculate these values. This exercise uses epoll for I/O Multiplexing which is one of the fastest ways for I/O multiplexing. It sends three ICMP ECHO messages to each of the hosts and prints their RTT values only if all the messages are received back.
4+
5+
# Design
6+
7+
For each address in the input hosts file, the program automatically detects if it is IPv4 or IPv6 and calls the appropriate function which sends the ECHO requests. Firstly, for each address, a RAW socket with ICMP protocol is created and it is connected to the IP address using connect call. This pseudo-connection is done on the kernel level so that only packets from that particular IP are received on this socket file descriptor. If the number of open files exceeds the system limit (commonly, 1024), then the program sleeps for a second to release some file descriptors which successfully received all 3 replies. These newly freed file descriptors are used for pending IPs.
8+
9+
The program keeps waiting for replies which are yet to be received. So, to exit the program in case it is waiting for lost packets, press Ctrl+C, which will print the number of IPs pinged and exits the program.
210

3-
This exercise develops a program which reads a text file with one IP(v4/v6) address per line and calulates RTT values of these IPs and print them in a line. This exercise made use of raw sockets and ICMP ECHO messages to calculate these values. This exercise uses epoll for I/O Multiplexing which is one of the fastest ways for I/O multiplexing. It sends three ICMP ECHO messages to each of the hosts and prints their RTT values onlu if all the messages are received back.
411

512

613
# How to Run:
714

8-
The following command is used to run on the machine. It compiles and runs the executable.
9-
10-
make run <file_name>
15+
The following command compiles the executable.
16+
17+
make compile
18+
19+
Superuser permissions are required because RAW sockets are used in the program.
20+
21+
sudo ./rtt.o <file_name>
22+
23+
Alternatively, you can provide CAP_NEW_RAW capability to the program and run without sudo.
1124

1225
To exit the process you can press Ctrl + C.

P5/readme.md

+29-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
1-
# P2 Pre-Fork Server
1+
# P5 Pre-Fork Server
22

3-
This exercise develops a pre-forking model for a web server which maintains a process pool to handle client requests. Server binds to a port and creates child processes. Each child process of the server acts as a server and accepts connection request and sleeps for one second then sends a dummy reply. Server maintains a minimum number of idle child processes `minSpareServers` and checks that at any point its not more than `maxSpareServers`. Each child handles a fixed number of accept requests before it is killed and a new child child is created.
3+
This exercise develops a pre-forking model for a web server which maintains a process pool to handle client requests. Server binds to a port and creates child processes. Each child process of the server acts as a server and accepts a connection request and sleeps for one second then sends a dummy reply. Server maintains a minimum number of idle child processes minSpareServers and checks that at any point its not more than maxSpareServers. Each child handles a fixed number of requests before it is killed and a new child is created, called recycling.
44

5+
# Design
56

6-
The communication between the child processes and server happens using UNIX domain sockets. Whenever the number of idle child processes is less than `minSpareServers` server adds 1 process to the process pool and waits for one second and then if its still less it will continue spawing child procesees exponentially to the server pool till its 32 processes per second and the spawing rate becomes constant after that.
7+
The communication between the child processes and server happens using UNIX domain sockets. Whenever the number of idle child processes is less than minSpareServers server adds 1 process to the process pool and waits for one second and then if it's still less it will continue spawning child processes exponentially to the server pool till its 32 processes per second and the spawn rate becomes constant after that.
78

8-
User can press `Ctrl + C` to print number of children currently active, and for each child how many clients it has handled.
9+
Users can press Ctrl + C to print the number of children currently active, and for each child how many clients it has handled.
910

1011

12+
Every child communicates with the parent with UNIX domain sockets created by socketpair. The parent uses I/O multiplexing across all these sockets to receive and send status messages and to self-regulate. Every process in the process pool can have 4 statuses:
13+
14+
* INIT
15+
* IDLE
16+
* BUSY
17+
* EXIT
18+
19+
INIT status indicates that the child was successfully forked but waits for acknowledgement from the parent. The parent acknowledges the newly forked child by sending an IDLE status message.
20+
21+
IDLE status indicates that the child is a part of the spare servers and that it can handle new requests. The IDLE status is used by the parent to regulate the number of spare servers.
22+
23+
BUSY status indicates that the child has accepted a connection request and is busy handling the request. Parent uses this status to remove this process from the spare process pool. After the request is handled, the child sends an IDLE status message to signal that it is ready to handle more requests.
24+
25+
EXIT status is sent by the child to the parent to signify that it has completed MaxRequestsPerChild requests and that this process will exit naturally. Once the parent receives this status, it will create a new child process to occupy its slot, which is called recycling. Recycling is done to make sure the spare process pool does not keep diminishing.
26+
27+
# Status messages
28+
29+
* @@ status messages are printed by the parent for every change happening in the process pool, i.e number of connections received and number of processes which became IDLE, and it is set/cleared using the VERBOSE flag in the code.
30+
#define VERBOSE 1 is the default parameter.
31+
32+
* status messages are printed when a change is done to the process pool by the parent in the process of regulation, i.e. number of idle/busy/total processes and the action taken by the parent to regulate and the status of the action done.
33+
34+
* ~~ status message is printed when Ctrl+C is pressed. This prints the number of connections handled till now by all the current processes in the pool.
35+
1136
# How to Run:
1237

1338
The following command is used to run on the machine. It compiles and runs the executable.

P6/readme.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
This exercise develops a P2P group communication system which allows users to create groups, join groups, send group messages and receive messages, request files and create polls in groups. The group communication among systems uses IP multicasting and broadcasting for the features. There is no central server to store data.
44

5+
# Design
6+
7+
All the clients need to be connected to the same LAN but on different machines. The program upon start will bind its main communication socket to port 5000. This is the socket from which it receives broadcast communication.
8+
9+
When a client creates or joins a multicast group, an entry is made in the program and a socket is created by the program to receive packets specifically from that group.
10+
11+
The main sockets and the group multicast sockets are I/O multiplexed to make the program responsive. A thread is created with the sole purpose of sending its file list to all multicast groups. Epoll timeouts and alarm with sleep are used to wait for a fixed amount of time to accumulate results from various groups. Multicast loopback is turned off to prevent the client receiving its own packets.
12+
13+
Receiving a file is done using TCP connection. When a client wants to receive a file from the groups, it sends a multicast message to all groups containing a temporary socket. When the receiver has the requested file, it opens a TCP connection to that socket and transfers the file in chunks. The requester receives the file in chunks and saves it in the data directory.
514

615
# Usage
716

817
# Creating and Joining group
918

1019
`create` command is used to create a group and the `join-group` command is used to join a group. The user who creates the group is already a member of the group. `find-group` command can be used to search if a group-name exists or not.
1120

12-
create <group_name> <group_ip> <group_port>
21+
create-group <group_name> <group_ip> <group_port>
1322
join-group <group_name>
1423
find-group <group_name>
1524

@@ -38,7 +47,7 @@ This exercise develops a P2P group communication system which allows users to cr
3847

3948
`create-poll` can be used to create a poll in a group which can have a maximum of 10 options to choose from. Questions and options must be enclosed in `" "`.
4049

41-
create-poll "<question>" <n_options> "<option1>" "<option2>" "<option3>"
50+
create-poll <group_name> "<question>" <n_options> "<option1>" "<option2>" "<option3>"
4251

4352

4453
# How to Run:

0 commit comments

Comments
 (0)