logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Earl BarwinAccounting
(5/5)

586 Answers

Hire Me
expert
Catherine Chanwai EarleLaw
(5/5)

715 Answers

Hire Me
expert
Vishal SindhwalComputer science
(5/5)

676 Answers

Hire Me
expert
Zkim HistHistory
(5/5)

866 Answers

Hire Me
C++ Programming

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.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme