<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CS360</title>
	<atom:link href="http://dna.cs.byu.edu/CS360/feed" rel="self" type="application/rss+xml" />
	<link>http://dna.cs.byu.edu/CS360</link>
	<description>Internet Programming</description>
	<lastBuildDate>Tue, 14 May 2013 09:04:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Reading Days TA Schedule</title>
		<link>http://dna.cs.byu.edu/CS360/uncategorized/reading-days-ta-schedule</link>
		<comments>http://dna.cs.byu.edu/CS360/uncategorized/reading-days-ta-schedule#comments</comments>
		<pubDate>Tue, 16 Apr 2013 18:53:11 +0000</pubDate>
		<dc:creator>javidpack</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=1723</guid>
		<description><![CDATA[This schedule subject to change. Feel free to ask us questions on things you don&#8217;t understand to prepare for viagra sin receta en madrid the final. Time Wed Thu 9:00 10:00 Javid Javid 11:00 Javid Javid 12:00 Javid Javid 1:00 Javid Javid 2:00 Javid Javid 3:00 Aaron 4:00 Aaron 5:00 Aaron 6:00 7:00 8:00 9:00]]></description>
			<content:encoded><![CDATA[<p>This schedule subject to change. Feel free to ask us questions on things you don&#8217;t understand to prepare for
<div style="display: none"><a href='http://compra-viagra-onlinee.com/'>viagra sin receta en madrid</a></div>
<p> the final.</p>
<table style="border-width: 0px;" border="1">
<tbody>
<tr>
<td>Time</td>
<td>Wed</td>
<td>Thu</td>
</tr>
<tr>
<td>9:00</td>
<td></td>
<td></td>
</tr>
<tr>
<td>10:00</td>
<td>Javid</td>
<td>Javid</td>
</tr>
<tr>
<td>11:00</td>
<td>Javid</td>
<td>Javid</td>
</tr>
<tr>
<td>12:00</td>
<td>Javid</td>
<td>Javid</td>
</tr>
<tr>
<td>1:00</td>
<td>Javid</td>
<td>Javid</td>
</tr>
<tr>
<td>2:00</td>
<td>Javid</td>
<td>Javid</td>
</tr>
<tr>
<td>3:00</td>
<td></td>
<td>Aaron</td>
</tr>
<tr>
<td>4:00</td>
<td></td>
<td>Aaron</td>
</tr>
<tr>
<td>5:00</td>
<td></td>
<td>Aaron</td>
</tr>
<tr>
<td>6:00</td>
<td></td>
<td></td>
</tr>
<tr>
<td>7:00</td>
<td></td>
<td></td>
</tr>
<tr>
<td>8:00</td>
<td></td>
<td></td>
</tr>
<tr>
<td>9:00</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/uncategorized/reading-days-ta-schedule/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project</title>
		<link>http://dna.cs.byu.edu/CS360/labs/project</link>
		<comments>http://dna.cs.byu.edu/CS360/labs/project#comments</comments>
		<pubDate>Fri, 08 Mar 2013 20:52:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=1690</guid>
		<description><![CDATA[Your task, should you choose to accept it, is to create a cool web application using one of the many web application frameworks that are out there. You decide what would be cool. I require the following in your web application: Use of a web application framework. For a description and list of frameworks, go [...]]]></description>
			<content:encoded><![CDATA[<p>Your task, should you choose to accept it, is to create a cool web application using one of the many web application frameworks that are out there. You decide what would be cool. I require the following in your web application:</p>
<ul>
<li>Use of a web application framework. For a description and list of frameworks, go to <a href="http://en.wikipedia.org/wiki/Web_application_framework">WikiPedia</a>. For those new to PHP, I would recommend CakePHP.</li>
<li>Model-View-Controller architecture &#8211; this should come via the framework</li>
<li>A database</li>
<li>AJAX</li>
<li>User login with some administrative user login to control and set things up</li>
</ul>
<div>The proposal part of the project is to send me an email describing your web application and how
<div style="display: none"><a href='http://farmacia-italiana-online.com/'>comprare cialis online</a></div>
<p> it meets these requirements. You should not proceed until I have had a chance to review your email and respond with suggestions or tell you it is approved.</p></div>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/labs/project/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homework #2 Answers Winter 2013</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-2-answers-winter-2013</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-2-answers-winter-2013#comments</comments>
		<pubDate>Fri, 22 Feb 2013 20:14:56 +0000</pubDate>
		<dc:creator>javidpack</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=1651</guid>
		<description><![CDATA[1. On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no child process is created, and errno is set appropriately. 2. NonZero Process: Global variable: 10 Stack variable: 29 Zero Process: Global variable: 12 Stack variable: [...]]]></description>
			<content:encoded><![CDATA[<p>1. On success, the PID of the child process is returned in the parent, and 0 is returned in the child. On failure, -1 is returned in the parent, no child process is created, and errno is set appropriately.</p>
<p>2. NonZero Process: Global variable: 10 Stack variable: 29<br />
Zero Process: Global variable: 12 Stack variable: 26</p>
<p>3. A condition where unintended results can occur because of concurrent modifications on a multithreaded computation.</p>
<p>4.The base of each is exec (execute), followed by one or more letters:<br />
e &#8211; An array of pointers to environment variables is explicitly passed to the new process image.<br />
l &#8211; Command-line arguments are passed individually to the function.<br />
p &#8211; Uses the PATH environment variable to find the file named in the path argument to be executed.<br />
v &#8211; Command-line arguments are passed to the function as an array of pointers.</p>
<p>5. Use fstat() or stat() and then S_ISDIR() to check if it is a directory and st_size to get the file size.</p>
<p>6.Sockets stay open (if this option is specified.)<br />
Additional Headers<br />
Host: header is required</p>
<p>7.A Cookie “…is a small string of text stored on a user’s computer by a web browser. A cookie consists of one or more name-value pairs containing bits of information such as user preferences, shopping cart contents, the identifier for a server-based session, or other data used by websites. It is sent as an HTTP header by a web server to a <a href='http://canadianpharmacyviiagra.com/'>canadian pharmacy no prescription</a> web client (usually a browser) and then sent back unchanged by client each time it accesses that server.”</p>
<p>8.latency = sendingOverhead + (distance / (.5*speedOfLight)) + (messageLength * 8/sendSpeed) + receivingOverhead = approx 800s</p>
<p>9. Not PHP example</p>
<blockquote><p>#!/usr/bin/perl</p>
<p>use CGI qw/:standard/;<br />
print header;<br />
print start_html(&#8216;CGI Sample Page&#8217;), h1(&#8216;CGI Sample Page&#8217;), start_form, &#8220;Text: &#8220;, textfield(&#8216;text&#8217;),p, submit(&#8216;Reverse&#8217;), submit(&#8216;To Upper&#8217;);<br />
if (param(&#8216;text&#8217;)) {<br />
if(param(&#8216;To Upper&#8217;)) {<br />
print h2(&#8220;Uppercase text:&#8221;);<br />
$text = param(&#8216;text&#8217;);<br />
$upper = uc($text);<br />
print ($upper);<br />
}<br />
if(param(&#8216;Reverse&#8217;)) {<br />
print h2(&#8220;Reversed text:&#8221;);<br />
$text = param(&#8216;text&#8217;);<br />
$rev = reverse($text);<br />
print ($rev);<br />
}<br />
}<br />
print end_form, end_html;</p>
</blockquote>
<p>10. PHP example</p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;?php<br />
if (isset($_REQUEST['val']) )<br />
{<br />
if(isset($_POST["Uppercase"])) {</p>
<p>echo strtoupper($_REQUEST["val"]);</p>
<p>} else{<br />
echo strrev($_REQUEST["val"]);</p>
<p>}<br />
}<br />
else<br />
{<br />
?&gt;<br />
&lt;body&gt;</p>
<p>&lt;form method=&#8221;post&#8221; action=&#8221;prob9.php&#8221; enctype=&#8221;multipart/form-data&#8221;&gt;<br />
Enter a value<br />
&lt;input type=&#8221;text&#8221; name=&#8221;val&#8221; /&gt;&lt;p /&gt;<br />
&lt;input type=&#8221;submit&#8221; name=&#8221;Reverse&#8221; value = &#8220;Reverse&#8221;/&gt;<br />
&lt;input type=&#8221;submit&#8221; name=&#8221;Uppercase&#8221; value = &#8220;Uppercase&#8221; /&gt;&lt;/form&gt;</p>
<p>&lt;?php<br />
}<br />
?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-2-answers-winter-2013/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performance Report Grading Rubric</title>
		<link>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric-2</link>
		<comments>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric-2#comments</comments>
		<pubDate>Wed, 06 Feb 2013 13:46:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=1626</guid>
		<description><![CDATA[Criteria Excellent Good Acceptable Poor Unacceptable Organization Ideas are arranged logically order viagra and support thesis.Writing is compelling and flows smoothly from one idea to the next Ideas are arranged logically and support the thesis. They are usually linked together and can be followed Ideas are arranged logically but don&#8217;t all support the thesis. The [...]]]></description>
			<content:encoded><![CDATA[<table border="1">
<tbody>
<tr>
<th>Criteria</th>
<th>Excellent</th>
<th>Good</th>
<th>Acceptable</th>
<th>Poor</th>
<th>Unacceptable</th>
</tr>
<tr>
<td>Organization</td>
<td>Ideas are arranged logically <a href='http://cheap-viagra-st.com/'>order viagra</a> and support thesis.Writing is compelling and flows smoothly from one idea to the next</td>
<td>Ideas are arranged logically and support the thesis. They are usually linked together and can be followed</td>
<td>Ideas are arranged logically but don&#8217;t all support the thesis. The reader is left to make connections.</td>
<td>Ideas are not arranged logically but the line of reasoning can be figured out.</td>
<td>Ideas are not arranged logically. The reader is unable to identify the line of reasoning and loses interest quickly.</td>
</tr>
<tr>
<td>Sentence Structure and Grammar</td>
<td>Sentences are well-phrased and varied in length and structure. They flow smoothly. Grammar is proper and mostly free of errors.</td>
<td>Sentences are well phrased and there is some variety in length and structure. The flow is generally smooth. There are occasional errors but nothing major or distracting.</td>
<td>Some sentences are awkwardly constructed. The writing has grammar and spelling errors that distract the reader.</td>
<td>Many sentences are awkward and poorly constructed. Grammar errors make the reader confused as to the meaning.</td>
<td>Sentence structure is very awkward making the paper very difficult to read. Grammar mistakes are common.</td>
</tr>
<tr>
<td>Purpose</td>
<td>Writers central purpose is clear throughout the paper.</td>
<td>The writing has a clear purpose, but the writer may sometimes digress from it.</td>
<td>The central purpose is not clear throughout the paper.</td>
<td>The central purpose is generally not clear.</td>
<td>There is no central purpose in the writing.</td>
</tr>
<tr>
<td>Content</td>
<td>The paper has a balanced presentation of the information that supports the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Introduction</td>
<td>The introduction is clear and guides the reader to the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td>There is no real introduction</td>
</tr>
<tr>
<td>Experimental Environment and Experiments</td>
<td>The Experimental environment is clearly explained. The experiments are appropriate to generate the needed data to support the central purpose.</td>
<td></td>
<td></td>
<td></td>
<td>The experimental environment is not explained</td>
</tr>
<tr>
<td>Presentation of Results</td>
<td>The paper makes good use of graphs, charts, and/or tables. Graphs and tables are clear and easy to understand and support the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td>Graphs are unreadable and not understandable and do not support the central purpose of the paper</td>
</tr>
<tr>
<td>Discussion of Results</td>
<td>The writing clearly and directly addresses the results and discusses specific issues of interest.</td>
<td></td>
<td></td>
<td></td>
<td>There is no real discussion of the results</td>
</tr>
<tr>
<td>Conclusion</td>
<td>The paper has an effective conclusion that does more than merely sum up the paper</td>
<td></td>
<td></td>
<td></td>
<td>The paper has no real conclusion</td>
</tr>
<tr>
<td>Length</td>
<td>The paper is appropriately long enough to meet the assignments needs and explain the authors arguments.</td>
<td></td>
<td></td>
<td></td>
<td>The paper is not at all long enough.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to CS360</title>
		<link>http://dna.cs.byu.edu/CS360/information/welcome-to-cs360</link>
		<comments>http://dna.cs.byu.edu/CS360/information/welcome-to-cs360#comments</comments>
		<pubDate>Thu, 13 Dec 2012 23:16:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=5</guid>
		<description><![CDATA[This is going to be a busy, but hopefully exciting semester.  During this course, we will develop a web server to help you understand what is going on under the covers when you write a web application.  We will become familiar with low level operating system functionality that is necessary in any multithreaded networking application.  We [...]]]></description>
			<content:encoded><![CDATA[<p>This is going to be a busy, but hopefully exciting semester.  During this course, we will develop a web server to help you understand what is going on under the covers when you write a web application.  We will become familiar with low level operating system functionality that is necessary in any multithreaded networking application.  We will also develop web applications with increasing degrees of
<div style="display: none"><a href='http://onlinee-pharmacy-no-prescription.com/'>online canadian pharmacy no prescription</a></div>
<p> sophistication.  Our emphasis will be in giving you experience with real technologies that you will be using in the future in whatever career path you choose.</p>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/information/welcome-to-cs360/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Homework 1 Answers</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-1-answers</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-1-answers#comments</comments>
		<pubDate>Tue, 14 Feb 2012 06:01:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=376</guid>
		<description><![CDATA[List five benefits that TCP adds to IP. (5 points) (http://www.garykessler.net/library/tcpip.html) guarantees delivery assures data integrity guarantees packet order prevents data duplication (adds checksums and sequence numbers to transmitted data) acknowledges the receipt of data data flow control In the OSI Reference Model, what layers are TCP, HTTP, IP, and Ethernet in? (4 points) (http://www.garykessler.net/library/tcpip.html) [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>List five benefits that TCP adds to IP. (5 points)<em><em><br />
(http://www.garykessler.net/library/tcpip.html)</em></em></p>
<ul>
<li>guarantees delivery</li>
<li>assures data integrity</li>
<li>guarantees packet order</li>
<li>prevents data duplication (adds checksums and sequence numbers to transmitted data)</li>
<li>acknowledges the receipt of data</li>
<li>data flow control</li>
</ul>
</li>
<li>In the OSI Reference Model, what layers are TCP, HTTP, IP, and Ethernet in? (4 points)<em><em><br />
(http://www.garykessler.net/library/tcpip.html)</em></em></p>
<ul>
<li>TCP: Transport Layer</li>
<li>HTTP: Application Layer</li>
<li>IP: Internet Layer</li>
<li>Ethernet: Network Interface Layer<br />
According to the 7-layer model (http://en.wikipedia.org/wiki/OSI_model), here are the answers:</li>
<li>TCP: Transport Layer</li>
<li>HTTP: Application Layer</li>
<li>IP: Network Layer</li>
<li>Ethernet: Data Link Layer OR Physical Layer</li>
</ul>
</li>
<li>List five HTTP status codes and their meanings. (5 points)<em><em><br />
(see http://en.wikipedia.org/wiki/List_of_HTTP_status_codes)</em></em></p>
<ul>
<li>100 Continue</li>
<li>200 OK</li>
<li>301 Moved Permanently</li>
<li>400 Bad Request</li>
<li>500 Internal Server Error</li>
</ul>
</li>
<li>Use telnet to ask for the cs.byu.edu index.html and index.php pages using a HTTP request. Include the response headers for both requests as your answer. (3 points)
<p style="padding-left: 30px;">telnet use: telnet {server} {port}</p>
<p style="padding-left: 60px;">{HTTP request goes here.. just hit return twice for the empty line}</p>
<p style="padding-left: 30px;">example: (The HTTP request in this example is bad, so you&#8217;ll need to change that part to get the index.html and index.php pages.)</p>
<div style="width: 100%;"><img class="aligncenter size-full wp-image-179" style="margin-left: 50px; margin-right: 50px;" title="picture-371" src="http://dna.cs.byu.edu/CS360/wp-content/uploads/2009/04/picture-371.png" alt="picture-371" width="467" height="418" /></div>
<div><em><br />
telnet www.cs.byu.edu 80<br />
Trying 192.168.9.49&#8230;<br />
Connected to secweb.cs.byu.edu.<br />
Escape character is &#8216;^]&#8217;.<br />
HEAD /index.html HTTP/1.0</em></div>
<p>HTTP/1.1 404 Not Found<br />
Date: Tue, 28 Apr 2009 03:19:3</p>
<p>&nbsp;</p>
<p>5.</p>
<pre>$ dig amazon.com

; &lt;&lt;&gt;&gt; DiG 9.7.3-P3 &lt;&lt;&gt;&gt; amazon.com
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 46784
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;amazon.com.			IN	A

;; ANSWER SECTION:
amazon.com.		21	IN	A	72.21.214.128
amazon.com.		21	IN	A	72.21.194.1
amazon.com.		21	IN	A	72.21.211.176

;; Query time: 69 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Thu Feb 23 22:09:47 2012
;; MSG SIZE  rcvd: 76</pre>
<pre>6. IP Addresses are allocated in blocks. Universities for example are given a 16 bit block of addresses which uses up 65536 addresses with one assignment.</pre>
<pre>7. gethostbyname() calls libraries that access the Domain Name System to look up the ip address of a given hostname.</pre>
<pre>8. GET requests send any arguments in the url and do not have a body. The arguments are then placed in the QUERY_STRING header witch is added as an environment variable</pre>
<pre>POST requests have a body. Form requests then have the arguments encoded in the body of a POST request.</pre>
<pre>9. Semaphore code errors are usually characterized by deadlock or times when threads freeze up. Another characteristic my be that multiple threads may access the same location and thus have unpredictable results.</pre>
<pre>10. User-mode threads are created and managed by a library. The kernel does not
<div style="display: none"><a href='http://online-pharmacy-st.com/'>viagra online pharmacy</a></div>

 see or manage user-mode threads. Kernel mode threads are managed by the kernel. If a user-mode thread blocks, the whole process blocks. If a kernel-mode thread blocks, it is the only thread that blocks. The kernel continues scheduling the other threads.</pre>
<pre></pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-1-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC Laboratory</title>
		<link>http://dna.cs.byu.edu/CS360/labs/mvc-laboratory</link>
		<comments>http://dna.cs.byu.edu/CS360/labs/mvc-laboratory#comments</comments>
		<pubDate>Fri, 14 Oct 2011 16:14:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=1196</guid>
		<description><![CDATA[Introduction In this lab you will demonstrate a Model-View-Controller (MVC) application written with PHP. PHP does not natively support any MVC-specific constructs, but a good programmer can design an MVC application without such aids. Our hope is that you will see the benefits of programming in this fashion, and gain an understanding of what’s happening [...]]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>In this lab you will demonstrate a Model-View-Controller (MVC) application written with PHP. PHP does not natively support any MVC-specific constructs, but a good programmer can design an MVC application without such aids. Our hope is that you will see the benefits of programming in this fashion, and gain an understanding of what’s happening “behind the scenes” of your favorite websites.</p>
<h1>What is MVC?</h1>
<p>Model-View-Controller (MVC) is a designation given to applications which separate their model (data), controller (business logic), and view (GUI). The intent of programming in such a fashion is to make it easy to modify one aspect of the application without having to make any heavy edits to another aspect. With a good MVC application, a programmer can easily switch the look and feel of his website without interfering with the functionality or data of that site. He could also decide to switch from one database system to another (say from MySQL to SimpleDB) without having to modify the functionality and look and feel of his site. In addition to that type of flexibility, MVC provides a clean, compartmentalized structure to your otherwise very messy codebase If you want to read more on the subject, Wikipedia has an excellent <a href="http://en.wikipedia.org/wiki/Model_view_controller">article</a>.</p>
<h1>What are we doing?</h1>
<p>You will be creating a simple web application in PHP which allows users to view and rate images uploaded by others. The website will have three pages which are accessible to the public and a fourth visible only to those with a valid login.</p>
<ol>
<li>Home page: This page will contain a brief explanation of the website and any other information you wish to convey to your visitors</li>
<li>Popular image page: This page will list the top ten most <em>popular</em> images in the database. Each image will have its own title displayed above it, and a brief description displayed below it. Users of your website will be able to rate any of these images by “liking” or “disliking” them. The rating submitted by a user must be recorded in the database entry associated with that image.</li>
<li>Recent image page: This page will be identical to the last one with the exception that it will display a list of the ten most <em>recent</em> image submissions in the database.</li>
<li>Image submission page: This functionality is only available to website administrators (those with a login). You do not have to set up a way for users to register. By default this page displays a login form. Upon successful login, a session cookie will be created so that the user does not have to log in every time the page is visited. Authenticated users will be presented with a form which allows them to select and upload an image from their computer to the website. In addition to selecting an image, they must give the image a title and description. The description can be no longer than 200 characters and the title must not be longer than 50 characters. When the form has been submitted (via<br />
POST), the web application will save a copy of the image to disk, and insert the image location, image title, image description, and current date into the database.</li>
<li>A <a href="http://students.cs.byu.edu/~cs360ta/img/">live demo</a> of the project is available.</li>
<li>Some <a href="http://img.phoenixteam.org/MVC.pdf">tips</a></li>
</ol>
<h2>Hints:</h2>
<p>The online <a href="http://us.php.net/manual/en/index.php">PHP manual</a> is a great resource. Simply search for a function or a keyword and you will be instantly exposed to all the information you could want on a topic, along with hundreds of code examples.</p>
<p>You can use the database on paintball. The PHP tutorial gives you all the info you need to use the database with PHP. If you would like to connect to the database using the mysql prompt, use the following command from the command line.</p>
<p>/users/faculty/snell/mysqlrun/bin/mysql -h <a href="http://paintball.cs.byu.edu/">paintball.cs.byu.edu</a> -P 5556 -u CS360 -p</p>
<p>The password for the database is the same as the username. Remember to be careful. You are sharing with other students in the class.</p>
<h1>How Should I Organize my Code for MVC?</h1>
<p>A good MVC design starts with your PHP file hierarchy. It will be useful to create three subdirectories within your application, one for each part of M-V-C. Within those folders should be placed any PHP files that are part of that aspect of MVC. A simple diagram of this is shown below. You can import external PHP files and use the functions contained in them by using the PHP <a href="http://php.net/manual/en/function.require.php">require()</a> and <a href="http://us.php.net/manual/en/function.include.php">include()</a> functions.</p>
<p><img class="aligncenter size-medium wp-image-1199" title="image001" src="http://dna.cs.byu.edu/CS360/wp-content/uploads/2011/10/image001.png" alt="" width="600" height="258" /></p>
<h1>What Should My Model Do?</h1>
<p>Your model is responsible for all interactions with the MySQL database. No controller
<div style="display: none"><a href='http://viagra-from--canada.com/'>viagra online canadian pharmacy</a></div>
<p> or view code should have any contact with MySQL. In essence, your model will simply provide an interface to your database. Imagine you have a model file called db.php. Some functions you may wish to include in your <em>db.php</em>file would be <em>insertImageData(), retrieveImageData(), changeImageRating()</em>, etc. These functions would take some parameters and then insert them into a SQL query. The SQL query would then be executed. Any data returned by the queries would be craftily placed in a PHP array and returned to the caller.</p>
<p>In addition to interacting with the database, your model code will also interact with the file system, where you will be saving images uploaded by authorized users. Although MySQL does allow<br />
the storing of binary data, it is best to keep such large data on disk when possible. So you will probably want another model file, say <em>img.php</em>, which contains a<br />
function for saving an uploaded image to some pre-determined directory. Finally, your model will also be responsible for retrieving user logon information for the login functionality of your website. A single function retrieving a user’s password for comparison by your controller code should suffice.</p>
<h2>Hints:</h2>
<p>Note that you will probably want some way to ensure that no two images have the same filename. One way to do this is to generate<br />
a GUID and use that as the filename. Another way is to use some integer value as your file names and simply increment it every time someone uploads an image. The first comment on the PHP manual <a href="http://php.net/manual/en/function.com-create-guid.php">page</a> for <em>guids</em> cites a quick and dirty way to generate GUIDs.</p>
<p>To save an uploaded file in PHP, use the <em>move_uploaded_file</em> function. Tizag provides a very simple and good <a href="http://www.tizag.com/phpT/fileupload.php">tutorial</a> for PHP<br />
file uploads.</p>
<p>The table you use for your image data should have 6 columns: ID, Title, Description, Path, Rating, and SubmissionDate.</p>
<ol>
<li>Path should be the path to the saved image file.</li>
<li>Rating will simply be an integer representing the net value of “likes” minus “dislikes” for that image.</li>
</ol>
<h1>What Should My Controller Do?</h1>
<p>Your controller code is responsible for validating user input and handling the bulk of the business logic for your application. In particular, your controller should be in charge of user authentication for the login page. It should also be responsible for creating a <a href="http://www.php.net/manual/en/function.session-start.php">session</a> after a user has logged in.</p>
<p>Additionally, you will employ functions in your controller to manage image uploading. The controller will verify that images uploaded by your users are actually images (by checking for a correct file extension, examining metadata, or anything in between). The controller will also be responsible for any image handling up until the call to the model functions which save an image to disk and insert image data into the database.</p>
<p>Your controller will also be in charge of user ratings of images. It will receive requests for rating changes, Calculate the new rating of images, and call the appropriate function in the model to execute the change (like changeImageRating()).</p>
<h2>Hints:</h2>
<p>A simple example of a PHP login script is <a href="http://needsecure.com/simple-php-login-script.shtml">available</a>. Feel free to mimic the functionality of this script, but beware that is it not made for an MVC application (its view is mixed with its controller and model). It should point you in the right direction though.</p>
<p>For image ratings, having a separate PHP file called <em>rateimage.php</em> might be useful. You can easily set the <em>action</em> attribute of a form tag to this file, thereby<br />
enabling it to handle all requests for image ratings. A similar method can be employed to handle login attempts by users.</p>
<h1>What Should My View Do?</h1>
<p>View code should consist mainly of plain HTML. The view is responsible only for displaying things to the user. No HTML should exist in any other part<br />
of your MVC application. You will probably have a view file for each page of the site. The view file for the home page could be entirely HTML, as it contains no dynamic data or programmatic<br />
functionality.</p>
<p>Another view file, perhaps called <em>showimages.php</em>, could contain the HTML for the image browsing pages. <em>showimages.php</em> would contain mostly HTML. However, for the retrieval and display of the image list, you would want to include a view function written in PHP. A function like <em>displayImages()</em> would call the model function <em>retrieveImageData()</em>, and parse the data returned. <em>displayImages()</em> would then print the parsed data to the user in HTML format.</p>
<h2>Hints:</h2>
<p>For those unfamiliar with HTML, <a href="http://www.w3schools.com/">W3Schools</a> will be useful for creating your views. They have many HTML tutorials and demos.</p>
<p>Dynamically linking in a PHP file from another one can be easily done using the PHP <a href="http://php.net/manual/en/function.require.php">require()</a> and <a href="http://us.php.net/manual/en/function.include.php">include()</a> functions. This might be useful for keeping function code out of the way of raw HTML.</p>
<p>Remember that you will need an index.php page to be used as your default document. You may simply use this as your<br />
homepage, or make clever use of <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html">mod_rewrite</a> to direct users to the appropriate pages.</p>
<h1>Requirements for pass off</h1>
<p>&nbsp;</p>
<h2>Pass your code off with the TA, and post the code on your class website.</h2>
<table border="1">
<tbody>
<tr>
<td>Passoff Level</td>
<td>Behavior</td>
<td>Points</td>
</tr>
<tr>
<td>Minimal Passoff</td>
<td>
<ul>
<li>You can display and submit images from and to your database and rate them using a MVC architecture. Clarification: You have ZERO echo, print, or other function calls in your model.</li>
<li>You have ZERO database or filesystem function calls in your view.</li>
<li>Your controller does all the error checking and navigation (and nothing else does)</li>
<li>your view does all the displaying (and nothing else does), and your model does all the storing and retrieving of data (and nothing else does).</li>
</ul>
</td>
<td>80%</td>
</tr>
<tr>
<td>Perfect Passoff</td>
<td>You have login functionality and an AJAX script for updating image ratings.</td>
<td>100%</td>
</tr>
<tr>
<td>Extra Credit</td>
<td>Early Passoff.</td>
<td>+5%</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/labs/mvc-laboratory/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Midterm Exam Review</title>
		<link>http://dna.cs.byu.edu/CS360/information/midterm-exam-review</link>
		<comments>http://dna.cs.byu.edu/CS360/information/midterm-exam-review#comments</comments>
		<pubDate>Sun, 23 May 2010 06:37:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=449</guid>
		<description><![CDATA[The midterm exam will be in the testing center. You may bring one hand written page of notes of your own making to the exam. The following questions should provide a good review for the exam: What does the listen() command viagra online canada pharmacy do and how is it related to the connection oriented [...]]]></description>
			<content:encoded><![CDATA[<p>The midterm exam will be in the testing center. You may bring one hand written page of notes of your own making to the exam.</p>
<p>The following questions should provide a good review for the exam:</p>
<ol>
<li>What does the listen() command
<div style="display: none"><a href='http://viagra-price-xll.com/'>viagra online canada pharmacy</a></div>
<p> do and how is it related to the connection oriented nature of TCP?</li>
<li>Is IP connection oriented?</li>
<li>Is Ethernet connection oriented?</li>
<li>Is TCP connection oriented?</li>
<li>Is HTTP connection oriented?</li>
<li>Is UDP connection oriented?</li>
<li>What are the 7 layers in the OSI model?</li>
<li>What does the bind() procedure in the socket library do? How does it interact with the TCP and IP layers of the protocol stack.</li>
<li>What is the port used in binding to a socket?</li>
<li>What is a socket? How does a web server use sockets to distinguish between different clients that connect to it?</li>
<li>What are the steps a web server must take in processing an HTTP request?</li>
<li>What are the differences between the way a web server deals with a GET or POST cgi request.</li>
<li>Is HTTP a stateless protocol?</li>
<li>What are the differences between a PUT and GET?</li>
<li>What separates the HTTP header from the message body?</li>
<li>What are the 3 ways for a web application to maintain session state?</li>
<li>Compare the pros and cons of each method of maintaining state?</li>
<li>Explain how an HTTP cookie works. How does a perl application use cookies to create persistant state.</li>
<li>What are the advantages and disadvantages of CGI?</li>
<li>What does the SECURE keyword indicate for a cookie?</li>
<li>What is the size limitation on cookies?</li>
<li>What are 3 types of data that  a Unix file descriptor can access?</li>
<li>What does the execve system call do?</li>
<li>What is a race condition?</li>
<li>What are the differences between threads and processes?</li>
<li>What does the fork() system call return?</li>
<li>What system call would you use to determine file information?</li>
<li>What system call would you use to change the stdout of a process?</li>
<li>Why would you want to use a thread pool instead of a single thread for serving requests from browsers?</li>
<li>Why would you want to use a thread pool instead of spawning a new thread for each request from a browser?</li>
<li>How does a proxy work and how does a web browser maintain a cache?</li>
<li>How does PHP compare to Perl as a web application language?</li>
<li>Given a network connection of 1000 Mbit/sec., sending overhead of 80 µsec &amp; receiving overhead of 100 µsec. a 10000 byte message (including the header), with a network layer that allows 10000 bytes in a single message.  What is the total time for the transaction to complete over a 1000 km distance assuming that the Speed of light ~ .3 km/µsec?</li>
<li>Explain how the web could be the Operating System of the future. In your answer, discuss features traditionally offered by an OS and explain how these could be provided over the web.</li>
<li>What does this php code do?
<pre>&lt;?php
session_start();
$access_count = $_SESSION['access_count'];
$access_count++;</pre>
<pre>$_SESSION['access_count'] = $access_count;</pre>
<pre>if ($access_count==1) {
  echo "the first time!";
} else {
  $message="accessed this page $access_count times.";
}
?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Access Count&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php  echo "$message"; ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/information/midterm-exam-review/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Final Exam Review</title>
		<link>http://dna.cs.byu.edu/CS360/information/final-exam-review</link>
		<comments>http://dna.cs.byu.edu/CS360/information/final-exam-review#comments</comments>
		<pubDate>Fri, 11 Dec 2009 21:13:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=749</guid>
		<description><![CDATA[The final exam will be in the testing center during finals.  You may bring one hand-written page of notes of your own making to the exam.  The exam will be comprehensive. The following should provide a good start to review for the exam: Review the questions from the midterm review Which HTTP request sends the [...]]]></description>
			<content:encoded><![CDATA[<p>The final exam will be in the testing center during finals.  You may bring one hand-written page of notes of your own making to the exam.  The exam will be comprehensive.</p>
<p>The following should provide a good start to review for the exam:</p>
<ol>
<li>Review the questions from the midterm review</li>
<li>Which HTTP request sends the CONTENT_LENGTH header?</li>
<li>What are the performance advantages and disadvantages of CGI and PHP?</li>
<li>Why is the information associated with Cookies stored in the browser?</li>
<li>What are some reasons for using the Model View Controller architecture?</li>
<li>What are some reasons for using PHP ?</li>
<li>What are some reasons for using CGI ?</li>
<li>Why would you use a Model-View-Controller architecture for Internet applications?</li>
<li>Why is regular expression syntax included in PHP, PERL and RUBY?</li>
<li>You had the opportunity to include semaphores in your web server lab to control access to the thread pool. What symptoms would you expect if the semaphore code was not working?</li>
<li>What separates headers from the http message body?</li>
<li>In a semaphore, what does the integer value represent?</li>
<li>What does AJAX stand for?</li>
<li>Review AJAX. How does AJAX work? What are the necessary pieces? How do AJAX requests differ from other requests?</li>
<li>What is Cross-site scripting (XSS) ?</li>
<li>How do you preserve state in HTTP?</li>
<li>Why would you want to use a public key system instead of a symmetric key?</li>
<li>Why would you want to use a symmetric key system instead of a public key?</li>
<li>Given p=5, q=11, e=23, d=7, encrypt the message=&#8221;6&#8243;.</li>
<li>What is the base Javascript object used for AJAX?</li>
<li>How could you prevent duplicate form submission?</li>
<li>What statistical distribution is memoryless?</li>
<li>You know that the user tolerance for delay in displaying a web page is 8.3 seconds. You are launching a new product and expect to have 1000requests/minute during the peak of your offering. You have a cluster of web servers using DNS round robin load balancing. The service time for each request averages .9 seconds with a standard deviation of .85 seconds. You currently have a cluster of 18 web servers dedicated to your service.
<ol>
<li>What is the utilization of each server?</li>
<li>What is the mean response time for a request?</li>
<li>What is the standard deviation of the response time?</li>
<li>How much time does each request spend waiting in the queue?</li>
<li>How many requests are waiting in the queue at any time?</li>
<li>What is the 90th percentile of the response time (90% of the requests will be satisfied in less than what time)?</li>
<li>How many servers would you need to have 90% of the requests satisfied in less than 8.3 seconds?</li>
</ol>
</li>
<li>You are serving MP3 files to the web from your office in Los Angeles. You have a customer in New York City that is complaining about
<div style="display:none"><a href='http://genericviagragoo.net/'>buy sildenafil online</a></div>
<p> his response time. He claims that the average time for him to download a 1.5MByte MP3 file is 50 seconds. His connection to the Internet is a 256Kbps DSL line. Your connection to the Internet is a 50Mbps T3(DS3) line. The speed of light is approximately 2*10^8m/sec and LA-NY = 2800 miles=4480km). The latency through the protocol stack on each end is 100usec. The peak utilization of your web server is 84% and your average service time is .4 seconds.</p>
<ol>
<li>What is the total latency for this connection?</li>
<li>How long does it take for the file to be sent through the bottleneck bandwidth?</li>
<li>What is the response time of the server?</li>
<li>Why is the customer experiencing this long response time?</li>
<li>What one thing could you change that would cause the greatest improvement in download time?</li>
<li>What would the download time be with this improvement?</li>
</ol>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/information/final-exam-review/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homework 3 Answers</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-3-answers</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-3-answers#comments</comments>
		<pubDate>Fri, 29 May 2009 02:12:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=523</guid>
		<description><![CDATA[PHP (5 points) Give three distinguishing features of PHP and give an example or describe each feature. example: PHP is be embedded in HTML code using special tags. &#60;HTML&#62;&#60;BODY&#62; &#60;?php code here; ?&#62; &#60;/BODY&#62;&#60;/HTML&#62; (see http://www.php.net/manual/en/intro-whatcando.php) PHP can be used on all major operating systems Choice of procedural or object-based programming styles Can output HTML, [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>PHP (5 points)<br />
Give three distinguishing features of PHP and give an example or describe each feature.<br />
example:<code> PHP is be embedded in HTML code using special tags.<br />
&lt;HTML&gt;&lt;BODY&gt; &lt;?php code here; ?&gt; &lt;/BODY&gt;&lt;/HTML&gt;</code><br />
<em><em>(see <a href="http://www.php.net/manual/en/intro-whatcando.php">http://www.php.net/manual/en/intro-whatcando.php</a>)</em></em></p>
<ul>
<li>PHP can be used on all major operating systems</li>
<li>Choice of procedural or object-based programming styles</li>
<li>Can output HTML, as well as images, PDF files, and other file formats</li>
<li>Supports a wide range of databases</li>
</ul>
<p><em>See slides for more features</em></li>
<li>PHP Page (10 points)<br />
Create a simple website in PHP showing off your PHP skills and knowledge of cookies.</p>
<ul>
<li>Allow the user to input the name, value, and expiration of the cookie. The expiration will be in seconds from the time the user submits the form, so set the cookie value as time() + ExpirationValue.</li>
<li>If there are any cookies, display a message showing each cookie name and value.</li>
<li>Cookies are set in PHP with the following command: <code>setcookie(name,value,expiration);</code> and are read from the $_COOKIE array.</li>
<li>Your goal is function, not elegance, so don&#8217;t worry about handling bad input.</li>
<li>Sample:<a href="http://students.cs.byu.edu/~superman/cookies.php">http://students.cs.byu.edu/~superman/cookies.php</a></li>
<li>Post a link to your web page as well as your PHP code in your homework</li>
</ul>
<p><em>Example:</em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<pre><code> &lt;?php $name
<div style="display: none"><a href='http://cialis-20mg-ed.com/' title='cialis online'>cialis online</a></div>

 = ""; $value = ""; $exp = ""; $postback = false; if(array_key_exists('name',$_POST)) { $postback = true; $name = $_POST['name']; $value = $_POST['value']; $exp = intval($_POST['exp']); setcookie("cookie[$name]", $value, time() +$exp); } $cookies = false; if (count($_COOKIE)&gt;0) $cookies = true; ?&gt; &lt;HTML&gt; &lt;HEAD&gt;&lt;TITLE&gt;CS360 Sample PHP Page&lt;/TITLE&gt;&lt;/HEAD&gt; &lt;BODY&gt; &lt;h1&gt;Cookie Chaos&lt;/h1&gt; &lt;form action="cookies.php" method="post"&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;Cookie Name: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Cookie Value: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="value"/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Cookie Expiration: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name = "exp"/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;input type="submit" value="Add Cookie"/&gt; &lt;/p&gt; &lt;/form&gt; &lt;?php if($postback) { echo "Added cookie "$name" with value "$value" and expiration in $exp seconds"; } ?&gt; &lt;?php if (($cookies &amp;&amp; array_key_exists('cookie',$_COOKIE)) || $postback) { echo "&lt;h2&gt;Cookies on your machine:&lt;/h2&gt;"; echo "&lt;TABLE&gt;&lt;TR&gt;&lt;TH&gt;Name&lt;/TH&gt;&lt;TH&gt;Value&lt;/TH&gt;&lt;/TR&gt;"; if ($cookies &amp;&amp; array_key_exists('cookie', $_COOKIE)) { foreach ($_COOKIE['cookie'] as $cName =&gt; $cValue) { echo "&lt;TR&gt;&lt;TD&gt;$cName&lt;/TD&gt; &lt;TD&gt;$cValue&lt;/TD&gt;&lt;/TR&gt;"; } } if ($postback) echo "&lt;TR&gt;&lt;TD&gt;$name&lt;/TD&gt;&lt;TD&gt;$value&lt;/TD&gt;&lt;/TR&gt;"; echo "&lt;/TABLE&gt;"; } ?&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre>
<p><em><code> </code></em><em><br />
</em></li>
<li>Your link</li>
<h3>Security</h3>
<li>Why would you want to use a public key system instead of a symmetric key?<br />
<em>Public key systems allow you to distribute new keys through an insecure medium.</em></li>
<li>Why would you want to use a symmetric key system instead of a public key?<br />
<em>The encryption speed is much faster and you don’t want to expose your public key to attacks.</em></li>
<li>Given p=5, q=11, e=23, d=7, encrypt the message=&#8221;6&#8243;.<br />
<code>6^23mod55 = 6^10mod55*6^13mod55 = 60466176mod55*13060694016mod55 = 1mod55*51mod55 = 51</code></li>
<li>Given p=5, q=11, e=23, d=7, decrypt the cyphertext=&#8221;6&#8243;.<br />
<code>6^7mod55=41</code></li>
<li>Given p=5, q=11, e=3, find the decryption key.<br />
<code>(p-1)(q-1)=40, 3*1mod40=3 … 3*17mod40=11, 3*18mod40=14, 3*19mod40=17, 3*20mod40=20 … 3*27mod40=1 the decryption key is 27</code></li>
<li>Outline the steps necessary to set up a SSL session.
<ul>
<li><em>Each browser is configured with a root CA public key</em></li>
<li><em>When a session is initiated, the server sends a certificate with the servers public key signed by the root CA</em></li>
<li><em>The client can verify certificate using the Root CA public key and now has the server public key</em></li>
<li><em>server and client agree on security capabilities.</em></li>
<li><em>Using the server public key, the client sends a DES key to the server</em></li>
<li><em>The DES key is used to encrypt the session</em></li>
</ul>
</li>
</ol>
<h3>Queuing Theory</h3>
<ol>
<ol>
<ul>
<li>You know that the user tolerance for delay in displaying a web page is 8.3 seconds. You are launching a new product and expect to have 1000requests/minute during the peak of your offering. You have a cluster of web servers using DNS round robin load balancing. The service time for each request averages .9 seconds with a standard deviation of .85 seconds. You currently have a cluster of 18 web servers dedicated to your service.
<ol>
<li>What is the utilization of each server?<br />
<em>Since the mean is nearly equal to the standard deviation, we assume an exponential distribution and use those equations. The total arrival rate is 1000/minute =16.6 per second. With 18 servers, the arrival rate for each server is 16.6/18=0.926 arrivals per second.<br />
<code>Service rate = 1/service time = 1.11/second. Utilization = arrival rate/service rate = 0.926/1.11=0.8334=83%</code></em></li>
<li>What is the mean response time for a request?<br />
<code>Tr=Ts/(1-utilization) = 0.9/(1-0.833)= 5.4 seconds</code></li>
<li>What is the standard deviation of the response time?<br />
<code>5.4 seconds</code></li>
<li>How much time does each request spend waiting in the queue?<br />
<code>Tw=utilization*Tr=.8334*5.4= 4.5 seconds</code></li>
<li>How many requests are waiting in the queue at any time?<br />
<code>w= (utilization^2)/(1-utilization) = .83^2/(1-.83)= 4.05 requests</code></li>
<li>What is the 90th percentile of the response time (90% of the requests will be satisfied in less than what time)?<br />
<code>mx(y)=Tr*ln(100/(100-y)) = 5.4 * ln(100/(1-90)) = 5.4*ln(10) = 5.4*2.3 = 12.4seconds</code></li>
<li>How many servers would you need to have 90% of the requests satisfied in less than 8.3 seconds?<br />
<code>mTr(r)=Tr*ln(100/(100-r))<br />
mTr(90)=Tr*ln(10)=[Ts/(1-ρ)]*2.3=8.3 sec<br />
2.3 Ts=(1-ρ)8.3 sec, 8.3 ρ = 8.3-2.3* Ts, ρ=(8.3-2.3* Ts )/8.3, ρ=.75</code><br />
<em>To get 75% utilization you would need more servers<br />
Utilization = arrival rate/service rate, .75=arrival rate / 1.11, arrival rate = .83/second<br />
Total arrival /nservers = .83, nservers = Total arrival/.83 = 16.6/.83 = 20 servers</em></li>
</ol>
</li>
<li>You are serving MP3 files to the web from your office in Los Angeles. You have a customer in New York City that is complaining about his response time. He claims that the average time for him to download a 1.5MByte MP3 file is 50 seconds. His connection to the Internet is a 256Kbps DSL line. Your connection to the Internet is a 50Mbps T3(DS3) line. The speed of light is approximately 2*10^8m/sec and LA-NY = 2800 miles=4480km). The latency through the protocol stack on each end is 100usec. The peak utilization of your web server is 84% and your average service time is .4 seconds.
<ol>
<li>What is the total latency for this connection?<br />
<code>Total latency = 2*100usec + 4480km*(1000m/1km)/2*10^8 m/s = 200usec + .0224sec = 0.2sec</code></li>
<li>How long does it take for the file to be sent through the bottleneck bandwidth?<br />
<code>(1.5MByte*1000KB/MB * 8 b/B)/256Kbps = 46.8 seconds</code></li>
<li>What is the response time of the server?<br />
<code>Tr=Ts/(1-utilization) = .4/(1-.84) = 2.5 seconds</code></li>
<li>Why is the customer experiencing this long response time?<br />
<em>His connection to the internet is too slow</em></li>
<li>What one thing could you change that would cause the greatest improvement in download time?<br />
<em>Increase his internet connection to 10Mbps</em></li>
<li>What would the download time be with this improvement?<br />
<code>(1.5MByte*1000KB/MB * 8 b/B)/10000Kbps = 1.17 seconds </code><br />
<em>Total download time would be 1.17 + 2.5 + .2 = 3.87<br />
</em></li>
</ol>
</li>
<li>Did you complete the student rating for the class  at <a href="https://studentratings.byu.edu/">https://studentratings.byu.edu/</a>?</li>
</ul>
</ol>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-3-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
