Name: __KEY________________________ SID: _________________________
Answer the following questions in the space provided, or as instructed by editing and adding files to your student account. Please write clearly and make clear your final solution to a question if you make changes or corrections (pencils are recommended). This test is open book / open source material, you may use any source materials you like and find helpful for this class. However, this is an individual test, no cell phones, IM or other collaboration will be allowed during the test.
|
For official grading use only. Total: ______/ 100 |
|||||||||||||||||||||||||
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
|
/8 |
/2 |
/7 |
/2 |
/2 |
/2 |
/4 |
/2 |
/2 |
/2 |
/2 |
/2 |
/4+1 |
/4+1 |
/4 |
/2+1 |
/2 |
/2 |
/3 |
/2 |
/3+1 |
/2 |
/4 |
/10 |
/10+2 |
/10 |
(8 pts) The following is a list of attributes of the UDP and TCP protocols. Place each attribute with the protocol that most appropriately displays the attribute:
reliable
slow
connectionless
unreliable
fast
connection oriented
streaming
packet oriented
UDP: __c (connectionless) d (unreliable), e (fast) h (packet oriented)______________
TCP: __a (reliable) b (slow) f (connection oriented) g (streaming) ________________
(2 pts) One common problem of designing and developing a system with multiple parts that act concurrently (e.g. several things happening at once) is that deadlocks may occur. A deadlock is a situation where:
the final result depends on whether A or B goes last
A gets selected to run more often, not allowing B to run
A is Big-Endian while B is Little-Endian
A is waiting for B while B is waiting for A
Answer: _____D________
(7 pts) Match the following tools/commands with the description of their purpose (you can draw lines and/or match the number with the letter).
|
D |
1) tcpdump |
a) report a snapshot of the current processes an their status
|
3 |
|
|
2) ping |
b) send a signal to a process
|
7 |
|
A or G |
3) ps |
c) configure a network interface
|
5 |
|
E |
4) netstat |
d) dump traffic on a network
|
1 |
|
C |
5) ifconfig |
e) print network connections, routing tables, interface statistics, etc.
|
4 |
|
F |
6) nslookup
|
f) query internet name servers |
6 |
|
B |
7) kill
|
g) report a snapshot of the current processes |
3 |
(2 pts) Another big problem of designing and developing a system with multiple parts that act concurrently is that a race condition may occur. A race condition is a situation where:
A is waiting for B while B is waiting for A
the final result depends on whether A or B goes last
A is Big-Endian while B is Little-Endian
A gets selected to run more often, not allowing B to run
Answer: ____B_________
(2 pts) Another difference of building a distributed systems is the need to deal with partial failures. Which of the following are types of partial failures that need to be dealt with in a distributed system:
A message or packet is lost in transmission
A node running a server goes down
A receive buffer becomes full
All of the above
Answer: ___D__________
(2 pts) A client/server architecture is one in which many clients communicate with a central server while a peer-to-peer architecture is one in which all processes exchange information equally. which of the following examples of distributed services is NOT implemented as a client/server architecture:
Mail protocols such as SMTP and POP
Bit Torrent
File Transfer Protocol (FTP)
Relational database distributed access systems like Oracle and MySql
Answer: ___B__________
(4 pts) The Hypertext Transfer Protocol (HTTP) specifies how programs exchange documents over the web, and is designed to be implemented using a client/server architecture. Mark each of the following applications as either a client or a server
Firefox: ___Client________
Apache: ___Server________
Internet Explorer: __Client_______
Internet Information Services (IIS): __Server________
(2 pts) The CGI protocol does not specify a particular programming language that must be used to write CGI applications:
True False
(2 pts) The Web Server passes information to a CGI process using:
Environment Variables
Standard Input
Procedure Call Invocations
a and b
All of the above
(2 pts) Which of the following mechanisms does the TCP protocol use in order to implement reliable service:
Acknowledgments
Retransmissions
Flow Control
Timeouts
a and b
All of the above
(2 pts) When writing unit tests, you should only write test cases that you expect to succeed
True False
(4 pts) What are the 4 typical steps that you would do to build and install a project from source on a Linux/Unix system that was developed using the make automated build tool:
1) ./configure
2) make
3) make test
4) make install
(4 pts) Fill in the following blanks
An IPv4 address consists of a total of how many bits: _32_______
The standard dotted IPv4 address notation consists of how many parts: __4________
Each part of the dotted IPv4 address consists of how many bits (hint a,b & c should be consistent with one another): __8______
An IPv6 address consists of a total of how many bits: ___128____
(Extra credit 1pt) I misled people in class, but a hexadecimal number in the range from 0000-FFFF actually represents a 16 bit number (each hexadecimal digit represents 4 bits). This implies that a full IPv6 address must consist of how many :: separated hexadecimal groups: ___8______
(4 pts) List two of the three main mechanisms we studied in this class for implementing a concurrent server (1 extra credit points for getting all 3 correct).
1) threads
2) fork child processes
3) I/O multiplexing using select
(4 pts) Match the protocol with the socket type constant that is used in the socket() function call to create a socket using the desired protocol. Draw a line from the socket type constant on the left to the corresponding protocol on the right:
Socket Type Protocol
SOCK_STREAM -> TCP IP
SOCK_SEQPACKET -> SCTP UDP
SOCK_RAW -> IP SCTP
SOCK_DGRAM -> UDP TCP
(2 pts) What is the IPv4 address associated with the loopback network interface? __127.0.0.1___________
(Extra Credit 1pt) What is the IPv6 loopback address: ____::1____________________________
(2 pts) When you open up a socket connection to the loopback interface, what will be the destination of your connection? ____the local machine / localhost / etc. ______________
(2 pts) Which end of a TCP connection goes into the TIME_WAIT state (circle one):
The end performing the active close
The end performing the passive close
(3 pts) Port numbers are divided into three ranges by the IANA. Briefly what are the names and purpose of these 3 ranges:
0 – 1023: __well-known services _________________________________________________
1024-49151: __IANA registered ports______________________________________________
49152-65535: __dynamic or private ports __________________________________________
The SIGCHLD signal is sent by the kernel when a child process writes data to its standard output for the parent to read:
True False
(3 pts) When we execute the following command:
[dharter@corvuslap ~]$ ps uwx
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dharter 2964 0.0 0.0 2296 1100 ? S 09:31 0:00 /var/tmp/lm_TMW.ld -z -c /var/tmp/lm_TMW.dat
dharter 3507 0.0 0.0 4596 308 ? Sl 09:32 0:00 /usr/bin/gpg-agent -s --daemon
dharter 3526 0.0 0.0 1584 132 ? S 09:32 0:00 start_kdeinit --new-startup +kcminit_startup
dharter 3527 0.0 0.1 28640 3772 ? Ss 09:32 0:00 kdeinit Running...
dharter 3530 0.0 0.1 17604 3196 ? S 09:32 0:01 dcopserver --nosid
dharter 3532 0.0 0.3 30384 6172 ? S 09:32 0:00 klauncher [kdeinit] --new-startup
dharter 10114 0.0 0.8 35608 16508 ? R 12:03 0:01 konsole
dharter 10117 0.0 0.0 4824 1560 pts/3 Ss 12:03 0:00 /bin/bash
dharter 10978 4.0 0.0 4524 948 pts/3 Z 12:38 0:00 ./socketserver.py
dharter 10979 4.0 0.0 4524 948 pts/3 R+ 12:38 0:00 ps uwx
S status means that the process is __sleep_________
R status means that the process is __running_______
Z status means that the process is __zombie________
(1 Extra Credit) what do Ss and Sl indicate? How about R+? s: session lead l: multithread +: foreground
(2 pts) A client/server architecture is one in which many clients communicate with a central server while a peer-to-peer architecture is one in which all processes exchange information equally. which of the following examples of distributed services is NOT implemented as a client/server architecture:
Mail protocols such as SMTP and POP
Bit Torrent
File Transfer Protocol (FTP)
Relational database distributed access systems like Oracle and MySql
Answer: ___B___________
(4 pts) A socket pair for a TCP connection contains 4 parts or a 4-tuple as we have referred to it in class (as seen when using the netstat command). What are the 4 parts designating a TCP socket connection:
__server ip________________
__server port______________
__client ip________________
__client port______________
(10 pts) The following are a list of function names (in the C socket api) that are used to creating clients and servers to communicate with each other using sockets:
accept()
bind()
close()
connect()
listen()
read()
socket()
write()
Write the typical sequence of elementary socket functions, in the correct order, that would be called to:
(Show the full set of steps that would be needed using the C language socket interface, some language's socket libraries, like Java, combine some of the above basic operations into single operations.)
A
)
create a TCP client:
B) create a TCP server:
(10 pts) There is currently a tcp client running from the host corvus.tamu-commerce.edu that is interacting with a server on the nisl server.
Create a tcpdump filter (tcpdump command is located at /usr/sbin/tcpdump) to determine the port number of the server that the client on corvus is communicating with. What is the port number of the server?
Server port number on nisl: 56187
(Extra Credit 2 pts) Further, what message is the client sending the server? What message, if any, is the server sending back to the client?
Client: Secret Phrase
Server: Linux is Fun
There is a flag that can be given to the netstat command in order to display the process id and the name of the program that has opened a given network connection. What is this flag? Use this flag to determine the process id (pid) and name of the command that is running the tcp server on nisl.
-p pid of server: 1225 name python ./SuperSecretTestServer.py
Use the ps command to determine who is the user who owns the running server in question. Which user is running the indicated server?
user: ssuh more full name: python ./SuperSecretTestServer.py
If you were the root/administrator of nisl, and you wanted to stop this running server, what command would you use to terminate the running process?
kill -9 1225
(10 pts) There is another server also running on the nisl server currently, not so secret this time, that can be found at port 54321. The server is a TCP server. Write a client (you may use whichever language you feel most comfortable with) to communicate with this server. You should create a new directory in your repository named test2. This program should be named TestClient.x (using the appropriate extension for the language you are using). Make sure you add and commit your new directory and the TextClient.x program to your repository when you are done.
The server implements the following (pseudo) protocol:
When the server receives a valid student user name, it will send back a keyword. Have your client fetch this keyword from the server and display it to standard output, along with the username you sent. For example:
[harry@nisl test2]$ ./TestClient.py
harry: TheHarryKey
The keyword is unique to each student. Upon receiving your keyword, you can use it to acquire your secret phrase from the server (again each phrase is unique to each username). Send your keyword as your second message from your client, and display the secret phrase you receive back from the server to standard output, for example:
Secret Phrase: “Harry's Secret Phrase!”
What was your secret phrase? _____Answer is unique to each student, example answer next page_
#!/usr/bin/env python
import sys, socket
buffer_size = 1024 # bytes
host = 'nisl.tamu-commerce.edu' # local machine (loopback address)
port = 54321 # hope nobody else is using it...
# AF_INET means 'Internet socket'.
# SOCK_STREAM means 'TCP'.
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))
# Send the message.
user = "harry"
sock.send(user)
# Receive and display the reply.
keyword = sock.recv(buffer_size)
print '%s: %s' % (user, keyword)
# Send the message.
sock.send(keyword)
# Receive and display the reply.
phrase = sock.recv(buffer_size)
print 'Secret Phrase: <%s>' % phrase
# Tidy up.
sock.close()
CSci 553, Test
2