Concept explainers
A.
IP addresses:
- The IP address denotes an unsigned integer that is 32-bit.
- The IP addresses is been stored by network programs in IP address structure.
- The addresses present in IP address structure are stored in network byte order.
- An unsigned 32-bit integer is transformed from host byte order to network byte order by “htonl” function.
- An unsigned 32-bit integer is transformed from network byte order host byte order by “ntohl” function.
- The IP address is presented to humans in a form known as “dotted-decimal” notation.
- Each byte is been represented by its corresponding decimal value and is separated by a period from other bytes.
Passing
- The arguments for “GET” requests are passed in the URI.
- The character “?” separates filename from the arguments.
- The character “&” separates each argument.
- The arguments do not allow spaces in it.
Server passes arguments to child:
- The server calls “fork” to create a child process and calls “execve” to run program in child’s context once it receives a request.
- The child process sets CGI environment variable values.
- The “adder” program can reference it at run time using “getenv” function of linux.
Output is sent by child:
- The dynamic content of a CGI program is to be sent to standard output.
- A CGI program sends dynamic content to standard output.
- It uses “dup2” function for redirecting standard output to connected descriptor associated with client.
- The result written to standard output by CGI program, it goes directly to client.
A.
Explanation of Solution
Modified C code:
//Define method
void clienterror(int fd, char *cause, char *errnum, char *shortmsg, char *longmsg);
//Define method
void echo(int connfd);
//Define main method
int main(int argc, char **argv)
{
//Declare variables
int listenfd, connfd;
//Call method
Getnameinfo((SA *) &clientaddr, clientlen, hostname, MAXLINE,port, MAXLINE, 0);
//Display message
printf("Accepted connection from (%s, %s)\n", hostname, port);
//Call method
echo(connfd);
//Close
Close(connfd);
}
//Define method
void echo(int connfd)
{
//Declare variable
size_t n;
//Declare array
char buf[MAXLINE];
//Declare variable
rio_t rio;
//Call method
Rio_readinitb(&rio, connfd);
//Loop
while ((n = Rio_readlineb(&rio, buf, MAXLINE)) != 0)
{
//If condition satisfies
if (strcmp(buf, "\r\n") == 0)
//Break
break;
//Call method
Rio_writen(connfd, buf, n);
}
}
Explanation:
- The method “echo” declares the variables first.
- It handles one HTTP response/request transaction.
- The value is been read using method “readinitb” and is stored.
- The value is been written into buffer using “written” method.
- The comparison is made until new line occurs.
B.
IP addresses:
- The IP address denotes an unsigned integer that is 32-bit.
- The IP addresses is been stored by network programs in IP address structure.
- The addresses present in IP address structure are stored in network byte order.
- An unsigned 32-bit integer is converted from host byte order to network byte order by “htonl” function.
- An unsigned 32-bit integer is converted from network byte order host byte order by “ntohl” function.
- The IP address is presented to humans in a form known as “dotted-decimal” notation.
- Each byte is been represented by its corresponding decimal value and is separated by a period from other bytes.
Passing program arguments to server:
- The arguments for “GET” requests are passed in the URI.
- The character “?” separates filename from the arguments.
- The character “&” separates each argument.
- The arguments do not allow spaces in it.
Server passes arguments to child:
- The server calls “fork” to create a child process and calls “execve” to run program in child’s context once it receives a request.
- The child process sets CGI environment variable values.
- The “adder” program can reference it at run time using “getenv” function of linux.
Output is sent by child:
- The dynamic content of a CGI program is to be sent to standard output.
- A CGI program sends dynamic content to standard output.
- It uses “dup2” function for redirecting standard output to connected descriptor associated with client.
- The result written to standard output by CGI program, it goes directly to client.
B.
Explanation of Solution
Request to TINY for static content:
GET / HTTP/1.1
Host: localhost:5000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Explanation:
- The given code denotes a request to “TINY” for static content.
- It echoes each and every request line.
- It echoes each and every request header.
- It takes a particular “Accept-Language” and “Accept-Encoding” for the content.
C.
IP addresses:
- The IP address denotes an unsigned integer that is 32-bit.
- The IP addresses is been stored by network programs in IP address structure.
- The addresses present in IP address structure are stored in network byte order.
- An unsigned 32-bit integer is converted from host byte order to network byte order by “htonl” function.
- An unsigned 32-bit integer is converted from network byte order host byte order by “ntohl” function.
- The IP address is presented to humans in a form known as “dotted-decimal” notation.
- Each byte is been represented by its corresponding decimal value and is separated by a period from other bytes.
Passing program arguments to server:
- The arguments for “GET” requests are passed in the URI.
- The character “?” separates filename from the arguments.
- The character “&” separates each argument.
- The arguments do not allow spaces in it.
Server passes arguments to child:
- The server calls “fork” to create a child process and calls “execve” to run program in child’s context once it receives a request.
- The child process sets CGI environment variable values.
- The “adder” program can reference it at run time using “getenv” function of linux.
Output is sent by child:
- The dynamic content of a CGI program is to be sent to standard output.
- A CGI program sends dynamic content to standard output.
- It uses “dup2” function for redirecting standard output to connected descriptor associated with client.
- The result written to standard output by CGI program, it goes directly to client.
C.
Explanation of Solution
Version of HTTP:
- The version of HTTP used by browser is HTTP 1.1.
- The output from “TINY” is been inspected for determining HTTP version of browser.
- The “TINY” denotes an iterative server that listens for connection requests on ports.
- The “TINY” executes infinite server loop; it accepts a connection request repeatedly.
- It performs the transaction and closes its end of connection.
- Hence, version of HTTP is “HTTP 1.1”.
D.
IP addresses:
- The IP address denotes an unsigned integer that is 32-bit.
- The IP addresses is been stored by network programs in IP address structure.
- The addresses present in IP address structure are stored in network byte order.
- An unsigned 32-bit integer is converted from host byte order to network byte order by “htonl” function.
- An unsigned 32-bit integer is converted from network byte order host byte order by “ntohl” function.
- The IP address is presented to humans in a form known as “dotted-decimal” notation.
- Each byte is been represented by its corresponding decimal value and is separated by a period from other bytes.
Passing program arguments to server:
- The arguments for “GET” requests are passed in the URI.
- The character “?” separates filename from the arguments.
- The character “&” separates each argument.
- The arguments do not allow spaces in it.
Server passes arguments to child:
- The server calls “fork” to create a child process and calls “execve” to run program in child’s context once it receives a request.
- The child process sets CGI environment variable values.
- The “adder” program can reference it at run time using “getenv” function of linux.
Output is sent by child:
- The dynamic content of a CGI program is to be sent to standard output.
- A CGI program sends dynamic content to standard output.
- It uses “dup2” function for redirecting standard output to connected descriptor associated with client.
- The result written to standard output by CGI program, it goes directly to client.
D.
Explanation of Solution
Meaning of HTTP headers:
- The details of each HTTP header is shown below:
- Accept:14.1:
- It can be used for specifying certain media types that are acceptable for response.
- Accept headers are used to indicate that request is limited specifically to a small set of desired types.
- It has same impact as in case of an in-line image request.
- Accept-Encoding: 14.3:
- The request header field is almost similar to “Accept”.
- It restricts the content-coding that are acceptable in response.
- Accept-Language: 14.4:
- The “Accept-Language” request header is similar to that of “Accept”.
- It restricts set of natural languages preferred as response to request.
- Connection: 14.10:
- The connection header field allows sender to specify options that are desired for particular connection.
- It must not be communicated by proxies over further connections.
- Host: 14.23:
- The host request header field would specify internet host and port number of resource being requested.
- The host field value denotes origin server’s naming authority or gateway given by original URL.
- It allows origin server or gateway in differentiating between ambiguous URLs.
- The root “/” server’s URL is used for multiple host names with single IP address.
- User-Agent: 14.43:
- The user-agent request header has information about user agent initiating the request.
- It is used for tracing protocol violations, automated acknowledgment of user agents for avoiding limitations of user agent.
- The requests are been added with the field.
- The field contains multiple product tokens and comments that identifies agent.
- It includes sub products that forms a significant part of user agent.
- The product tokens are listed in order of their significance for application identification.
- Accept:14.1:
Want to see more full solutions like this?
Chapter 11 Solutions
Computer Systems: A Programmer's Perspective Plus Mastering Engineering With Pearson Etext -- Access Card Package (3rd Edition)
- 1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0arrow_forwardAnalyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related. Refer to the raw data (table):arrow_forward3A) Generate a hash table for the following values: 11, 9, 6, 28, 19, 46, 34, 14. Assume the table size is 9 and the primary hash function is h(k) = k % 9. i) Hash table using quadratic probing ii) Hash table with a secondary hash function of h2(k) = 7- (k%7) 3B) Demonstrate with a suitable example, any three possible ways to remove the keys and yet maintaining the properties of a B-Tree. 3C) Differentiate between Greedy and Dynamic Programming.arrow_forward
- What are the charts (with their title name) that could be use to illustrate the data? Please give picture examples.arrow_forwardA design for a synchronous divide-by-six Gray counter isrequired which meets the following specification.The system has 2 inputs, PAUSE and SKIP:• While PAUSE and SKIP are not asserted (logic 0), thecounter continually loops through the Gray coded binarysequence {0002, 0012, 0112, 0102, 1102, 1112}.• If PAUSE is asserted (logic 1) when the counter is onnumber 0102, it stays here until it becomes unasserted (atwhich point it continues counting as before).• While SKIP is asserted (logic 1), the counter misses outodd numbers, i.e. it loops through the sequence {0002,0112, 1102}.The system has 4 outputs, BIT3, BIT2, BIT1, and WAITING:• BIT3, BIT2, and BIT1 are unconditional outputsrepresenting the current number, where BIT3 is the mostsignificant-bit and BIT1 is the least-significant-bit.• An active-high conditional output WAITING should beasserted (logic 1) whenever the counter is paused at 0102.(a) Draw an ASM chart for a synchronous system to providethe functionality described above.(b)…arrow_forwardS A B D FL I C J E G H T K L Figure 1: Search tree 1. Uninformed search algorithms (6 points) Based on the search tree in Figure 1, provide the trace to find a path from the start node S to a goal node T for the following three uninformed search algorithms. When a node has multiple successors, use the left-to-right convention. a. Depth first search (2 points) b. Breadth first search (2 points) c. Iterative deepening search (2 points)arrow_forward
- We want to get an idea of how many tickets we have and what our issues are. Print the ticket ID number, ticket description, ticket priority, ticket status, and, if the information is available, employee first name assigned to it for our records. Include all tickets regardless of whether they have been assigned to an employee or not. Sort it alphabetically by ticket status, and then numerically by ticket ID, with the lower ticket IDs on top.arrow_forwardFigure 1 shows an ASM chart representing the operation of a controller. Stateassignments for each state are indicated in square brackets for [Q1, Q0].Using the ASM design technique:(a) Produce a State Transition Table from the ASM Chart in Figure 1.(b) Extract minimised Boolean expressions from your state transition tablefor Q1, Q0, DISPATCH and REJECT. Show all your working.(c) Implement your design using AND/OR/NOT logic gates and risingedgetriggered D-type Flip Flops. Your answer should include a circuitschematic.arrow_forwardA controller is required for a home security alarm, providing the followingfunctionality. The alarm does nothing while it is disarmed (‘switched off’). It canbe armed (‘switched on’) by entering a PIN on the keypad. Whenever thealarm is armed, it can be disarmed by entering the PIN on the keypad.If motion is detected while the alarm is armed, the siren should sound AND asingle SMS message sent to the police to notify them. Further motion shouldnot result in more messages being sent. If the siren is sounding, it can only bedisarmed by entering the PIN on the keypad. Once the alarm is disarmed, asingle SMS should be sent to the police to notify them.Two (active-high) input signals are provided to the controller:MOTION: Asserted while motion is detected inside the home.PIN: Asserted for a single clock cycle whenever the PIN has beencorrectly entered on the keypad.The controller must provide two (active-high) outputs:SIREN: The siren sounds while this output is asserted.POLICE: One SMS…arrow_forward
- 4G+ Vo) % 1.1. LTE1 : Q B NIS شوز طبي ۱:۱۷ کا A X حاز هذا على إعجاب Mohamed Bashar. MEDICAL SHOE شوز طبي ممول . اقوى عرض بالعراق بلاش سعر القطعة ١٥ الف سعر القطعتين ٢٥ الف سعر 3 قطع ٣٥ الف القياسات : 40-41-42-43-44- افحص وكدر ثم ادفع خدمة التوصيل 5 الف لكافة محافظات العراق ופרסם BNI SH ופרסם DON JU WORLD DON JU MORISO DON JU إرسال رسالة III Messenger التواصل مع شوز طبي تعليق باسم اواب حمیدarrow_forwardA manipulator is identified by the following table of parameters and variables:a. Obtain the transformation matrices between adjacent coordinate frames and calculate the global transformation matrix.arrow_forwardWhich tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selectionarrow_forward
- A+ Guide To It Technical SupportComputer ScienceISBN:9780357108291Author:ANDREWS, Jean.Publisher:Cengage,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningLINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.Computer ScienceISBN:9781337569798Author:ECKERTPublisher:CENGAGE L