Question: C++ QUESTION!!!! NEED HELP WITH THIS QUESTION!!! PLEASE USE A SINGLY-LINKED LIST IN SOLVING THE PROBLEM. THERE IS SOME LOGIC PROVIDED AT THE END OF
C++ QUESTION!!!!
NEED HELP WITH THIS QUESTION!!! PLEASE USE A SINGLY-LINKED LIST IN SOLVING THE PROBLEM. THERE IS SOME LOGIC PROVIDED AT THE END OF THE PAGE TO HELP IN SOLVING THE PROBLEM.
UDP packet recombination
Description ----------- In this assignment you are to read in packets of information (ala the internet) and combine the packets together to form a message.
Layout of each record
1 - 4 sequence number used to store the information 5 - 16 data the actual data 17 - 17 a dot ignore 18 - 19 cr/lf ignore
You are to read in the separate lines into a structure that is NOT an array (or a vector or a map), and output the data, in order, by sequence number. Do not display the sequence number. Whenever you see a =+ in the data, remove those characters and replace them with a newline. (Gotcha: sometimes the = and the + are in different packets.)
The interesting part of this assignment is that as soon as the next expected packet number has been read in you should output the data in the packet and also output the data in packets (that you have received) that follow the current packet (consecutively). For example, you can't do any output until you have read packet 1. But once you have read packet 1 you can output packet 2, and packet 3, and packet 4, and packet 5, since they have already been read in and stored someplace. After the packet has been displayed, discard the packet.
Input Data ---------- 4rnighan - . 9is a compute. 26ls or GOTO's. 79ibraries.=+=. 20acilities=+s. 67the first=+s. 24n the page, . 2ion to C - . 57efinitions. . 63ave a main. . 6ories, Murra. 3 Brian W. Ke. 41ilities.=+=+. 1An Introduct. 40ucturing fac. 60, and in fac. 84ons is by ar. 10r language a. 5Bell Laborat. 71invoke other. 95nts, indicat. 25without labe. 82ting data be. 8 Jersey. C . 13. C lets yo. 7y Hill,=+New. 52or the proce. 18as decent co. 29e that is co. 22can be read . 80+One method . 21o your code . 44one or more . 47ilar to the=. 81of communica. 98e the statem. 86e=+parenthes. 43consists of . 68tatement of . 38 provides go. 90und the argu. 99ents=+of the. 46hich are sim. 49nd subroutin. 88 the functio. 92ere main=+is. 103d with a sem. 102tatements en. 37tion; and it. 101Individual s. 72 functions t. 96ed by ( ). T. 45functions, w. 69main. main w. 27;=+it lets y. 73o perform it. 53dures of PL/. 16learly and s. 42A C program . 51ran program . 77ogram, and o. 74s=+job, some. 94of no argume. 12many systems. 64 Execution o. 11vailable on . 93 a function . 87es following. 78thers from l. 31t being too . 28ou write cod. 35nd good prog. 91ment list; h. 75 coming from. 59h a function. 97he {} enclos. 62grams must h. 14u=+write you. 30mpact withou. 23straight dow. 17imply - it h. 76 the same pr. 65f the progra. 19ntrol flow f. 106=+free-forma. 54I, and=+perh. 61t=+all C pro. 89n name surro. 56ernal data d. 50es of a Fort. 33+encourages . 105re otherwise. 15r programs c. 66m begins at . 32cryptic; it=. 104icolon but a. 85guments. Th. 83tween functi. 39od=+data-str. 48+functions a. 100 function. . 107t.=+=+ . 58 main is suc. 55aps some ext. 70ill usually . 34modularity a. 36ram organiza.
=====================================================
If you are interested in the logic that I used to solve the problem, then look below. I extracted the comments out of the program I wrote and they are listed below.
packet4.c define the structure to be used function: insert an item into an ordered list main program open the file main loop read in the data in the packet allocate a node, put stuff in there, then insert the node into the list while the head item in the list is the next one expected remove the node from the list and print the info increment the 'next one expected' counter endloop close the file endmain
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
