Earn Higher Grades With Instant Assignment Help.Ask Question!

C++ Programming
(5/5)

Design and implement a C++ program to do the following tasks with threads.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Part 1.

First, create a folder (a4part1 in a4 folder) for your work of this part.                       

Consider ping command.

Note. For a reference, you may like to read about ping command in wiki:

https://en.wikipedia.org/wiki/Ping_%28networking_utility%29

Here are a few examples of ping command: ping -c 3 www.utdallas.edu

This ping command will send a ping ICMP packet to check whether www.utdallas.edu server receives a ping packet and send it back to the system (cs1.utdallas.edu). The -c option sets the number of times for ping ICMP packet to be sent (e.g., 3 times) as shown below.

{cslinux1:~} ping -c 3 www.utdallas.edu

PING www.utdallas.edu (10.182.71.70) 56(84) bytes of data.

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=1 ttl=248 time=0.745 ms

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=2 ttl=248 time=0.777 ms

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=3 ttl=248 time=0.743 ms

 

--- www.utdallas.edu ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2001ms

rtt min/avg/max/mdev = 0.743/0.755/0.777/0.015 ms

{cslinux1:~} ping -c 3 www.google.com

PING www.google.com (172.217.6.132) 56(84) bytes of data.

64 bytes from dfw25s16-in-f4.1e100.net (172.217.6.132): icmp_seq=1 ttl=49 time=2.90 ms

64 bytes from dfw25s16-in-f4.1e100.net (172.217.6.132): icmp_seq=2 ttl=49 time=2.90 ms

64 bytes from dfw25s16-in-f4.1e100.net (172.217.6.132): icmp_seq=3 ttl=49 time=2.93 ms

--- www.google.com ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 2.906/2.916/2.933/0.012 ms

The system runs the ping command and prints the result. It shows for each ping: (1) the size of packet received (64 bytes), (2) the server responded to ping (DNS name and IP address), (3) the sequence number of ICMP packet (1,2,3 in this case), (4) the limits for the number of network hops (TTL) (=49), (5) round trip time in ms (rtt) (=0.745, 0.777, 0.743). At the end it lists the summary of the ping commands. In this example, it sent 3 packets, 3 received, none of the packet lost, and total time (of 2002 ms or about 2 seconds) to be done. The rtt (round-trip time) statistics of minimum, average, maximum time, with standard deviation in ms.

Design and implement a C++ program to do the following tasks with threads.

Name the program: a4pingThread.cpp

Name the executable: a4pingThread

(1) The program runs to read an input file (a4ping1Data.txt). Each line of the file contains three arguments, to run "ping" command as shown below.

      www.utdallas.edu 5 3

      www.utdallas.edu 10 5

      www.google.com 15 3

The first argument is a host name (e.g., www.utdallas.edu) for the ping command, and the second argument is the number for "-c" option (the number of times of ICMP packet sent and returned) where the range of it is from 1 to 20 (inclusively). The third argument is for the number of the threads to be created, to run this ping command with -c option.

(2) The program (the parent process) creates a number of threads ranging from 1 to 5, specified by the third argument in the input data file. The parent waits all the threads to be terminated with the ping command. Each thread runs the ping command as specified and then to be terminated. With a pipe shared by each thread and the parent process, the parent process gets the access of the result of each ping command run by a thread. With dup or dup2, the parent process reads the output of each thread.     

(3) The parent process processes the results of the ping command run by these threads. Reading each line of ICMP packet result, the program gets rtt times. Out of these rtt times, it will find or compute the number of packets transmitted, the minimum rtt time, maximum rtt time, and average rtt times, and standard deviation of rrt times, to be compared with the summary of the ping command (at the end).

PING www.utdallas.edu (10.182.71.70) 56(84) bytes of data.

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=1 ttl=248 time=0.745 ms

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=2 ttl=248 time=0.777 ms

64 bytes from lb-int-ti-1a.utdallas.edu (10.182.71.70): icmp_seq=3 ttl=248 time=0.743 ms

--- www.utdallas.edu ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2001ms

rtt min/avg/max/mdev = 0.743/0.755/0.777/0.015 ms

(4) The program should print the status of each step with a proper heading. For example,

      Step1. a3ping3 process starts. pid=517

      Step2. Ready to read the input file: a3ping3Data.txt

      Step3. Input Data is: www.utdallas.edu 5 3

 

      Step4. Create Threads

    Thread 1 (tid=1001) to run: ping -c 5 www.utdallas.edu

                Thread 2 (tid=1002) to run: ping -c 5 www.utdallas.edu

                Thread 3 (tid=1003) to run: ping -c 5 www.utdallas.edu

                       

      Step5. All Threads are terminated. The parent processing the results

           Processing Thread 1 result

            Read and print each line, to be processed

PING www.utdallas.edu (10.182.71.70) 56(84) bytes of data. …

 

            Processing Thread 2 result

            Read and print each line, to be processed

   PING www.utdallas.edu (10.182.71.70) 56(84) bytes of data. …

 

            Processing Thread 3 result

            Read and print each line, to be processed

   PING www.utdallas.edu (10.182.71.70) 56(84) bytes of data. …

 

      Step6. Summary of ping command

        For example, the input line read for this request, the total number of packets sent for what DNS Name (e.g., www.utdallas.edu), the total time (real, user, etc.) for this request, and a trailer message saying that it is done.

And the program repeats Step3 to Step6 for next input line until it is done.

      Step7. End of the program run

 

(5) Test the program with the following data file containing the following test cases:

      www.utdallas.edu 5 3

      www.utdallas.edu 10 5

      www.google.com 15 3

(6) Provide Makefile. You may combine all programs in this part into one Makefile.

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
900 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
684 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
694 Answers Hire Me