Midterm Review

uptightexampleΔίκτυα και Επικοινωνίες

24 Οκτ 2013 (πριν από 3 χρόνια και 8 μήνες)

64 εμφανίσεις

Midterm Review

October
19
-
22

Closed book

one hand written page of
notes of your own making

Seven Layer Model

Application


Presentation


Session


Transport

Network


Data Link


Physical


Network


Data Link


Physical


Network


Data Link


Physical


Application


Presentation


Session


Transport

Network


Data Link


Physical


Email, FTP, www


cinteger size, big endian


synchronization, name space


reliability, congestion control

Routing

address


framing

errors


electrical

signals

Questions


What does the bind() procedure in the socket
library do? How does it interact with the TCP
and IP layers of the protocol stack.


What is a socket? How does a web server use
sockets to distinguish between different clients
that connect to it?

Web Operating System

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.


Scheduling?


Service Small requests first?

File System?


URL

Access Control?


Security

Virtual Memory?


Cache Replacement

Questions


What are the steps a web server must take in processing an HTTP
request?


What are the differences between the way a web server deals with a
GET or POST cgi request.


Is HTTP a stateless protocol?


What are the 3 ways for a web application to maintain session state?


URL Rewriting


Hidden Fields


Cookies


Compare the pros and cons of each method.


Explain how an HTTP cookie works. How does a perl application use
cookies to create persistant state.


What does the SECURE keyword indicate for a cookie?


Total Latency Example


1000 M
bit
/sec., sending overhead of 80 µsec
& receiving overhead of 100 µsec.


a 10000
byte

message (including the header),
allows 10000 bytes in a single message


3 situations: distance 1000 km v. 0.5 km v.
0.01


Speed of light ~ 300,000 km/sec (1/2 in
media)


Latency
0.01km

=


Latency
0.5km

=


Latency
1000km

=

Total Latency Example


1000 M
bit
/sec., sending overhead of 80 µsec & receiving
overhead of 100 µsec.


a 10000
byte

message (including the header), allows
10000 bytes in a single message


3 situations: distance 1000 km v. 0.5 km v. 0.01


Speed of light ~ .3 km/µsec


Latency
0.01km

= 80 + 0.01km / (50% x .3)


+ 10000 x 8 / 1000 Mbit/s + 100 ~
260
µsec


Latency
0.5km

= 80 + 0.5km / (50% x .3)


+ 10000 x 8 / 1000 Mbit/s + 100 ~
263
µsec


Latency
1000km

= 80 + 1000 km / (50% x .3)


+ 10000 x 8 / 1000 Mbit/s + 100 ~
6926
µsec


Long time of flight => complex WAN protocol

Questions


How do signals work with threads and processes?


Understand the implementation details and parameters for SysV
semaphores.


Compare and contrast user level and kernel level threads.


What are the differences between threads and processes?


What does the fork() system call return?


What system call would you use to determine file information?


What system call would you use to change the stdout of a process?


Why would you want to use a thread pool instead of a single thread
for serving requests from browsers?


Why would you want to use a thread pool instead of spawning a
new thread for each request from a browser?


From an Operating Systems perspective, what is the difference
between a process and a thread?

Everything is an object…
even numbers

Calling methods


Methods called through the
dot

.


operator:





MyObject.my_method

(sometimes dot is omitted
because the caller is implicit).


Methods can be
concatenated:
MyObject.my_method(a,b).another
_method(d).another_one


Parenthesis after the method
name are currently optional,
but recommended in most
cases


Calling a method means
sending a message to the
calling object:
MyObject.my_method(a,b)

is actually syntax sugar for

MyObject.send(

my_method

,a,b)

Creating methods



Methods are created through the use of the
def

keyword



Methods start with a lowercase letter


The
return

keyword is optional, as the last evaluated expression
is implicitly returned


Creating methods


Methods that answer a question, usually end with a

?

, while

destructive


methods with a

!




We said that numbers are objects… not special

primitive


types. We
can even define our own methods for them.














Arbitrary number of arguments, and default values are also
allowed:

Strings

Arrays

Hashes


Hashes are dictionaries composed of key/value pairs.


Hashes are associative Arrays that have keys as
indexes.


The keys are often strings or symbols.

# Empty hashes

h1 = {}

h2 = Hash.new


votes = {

yes


=> 23,

no


=> 40,

n/a


=> 4}


votes[

yes

]

votes[

maybe

]

votes[

maybe

] = 11


votes



votes.delete(

n/a

)

votes


#=> {}

#=> {}


#=> {

yes


=> 23,

no


=> 40,

n/a


=> 4}


#=> 23

#=> nil

#=> 11


#=> {

yes


=> 23,

no


=> 40,

n/a


= 4,


maybe


=> 11}


#=> 4

#=> {

yes


=> 23,

no


=> 40,

maybe


=> 11}

Regular Expressions


Using Regular
Expressions


you can work on
strings


through patterns



Regexp are
efficiently


implemented in
Ruby and


natively
accessible.



Create Regexp
with
%r{}
,
/ /

or


Regexp.new()

Common Control
structures

Iterators &

blocks


Blocks are nameless/anonymous

functions that capture the container

environment.



Variables used within a block need

to be previously declared in order

to use their values outside the block.



Iterators are a convenient way for

accessing info stored in Array, Hashes,

and collections of data.