1client initiates, server responds
client-server model
2network interface card. either wifi or ethernet
NIC
3ethernet is a bus network. Ethernet listens to see if the wire is busy. Then if it's not busy it will send the info on the bus. T or F
T
4A repeater. Will extend ethernet networks and broadcast anything that is sent to it right back out.
Hub
5A more sofisticated Hub that connects hubs together. Will learn where to send specific information based on the most frequent routes. Still on LAN and deals with frames.
Bridge
6devices that create the "internet" which spans Wide Area Networks. Handles IP adresses and TCP. Also bridges the gap between incompatible protocols. allow Point-to-Point phone connections
Router
7protocol that defines internet addressing. Is unreliable. store and forward. out of order on its own. ROGERS DEFINITION: provides the basic naming scheme and a delivery mechanism that can send packets, known as datagrams, from one Internet host to any other host.
IP
8protocol that adds reliability to IP. Ensures delivery of packets and provides in order delivery. ROGERS DEF: It provides reliable full duplex (bidirectional) connections between processes
TCP
9Clients and Servers are Processes. NOT machines (hosts) T or F
T
10Some wires and a small box
Ethernet segment
11A chunk of bits that is sent from one host to another ON LAN
frame
12Extends IP slightly just so that packets/datagrams can be sent from process to process instead of host to host
UDP (unrealiable Datagram Protocol)
13Client calls Sockets interface, sockets calls kernel for TCP/IP stuff (NOT A QUESTION JUST TYPE T) this is how they are layered.
T
14unsigned 32-bit integer. stored in the structure called in_addr which is in network byte order.
IP address
15What is the function that converts byte order host to network short
htons()
16What is this notation? (128.2.194.242)
dotted-decimal
17You convert dotted decimal to hex by taking each number between the dots and converting it to hex. 128.2.194.242 = 0x80 02, C2, F2 T or F
T
18What command shows the dotted decimal address of each NIC
ifconfig
19a human-friendly representation of an IP address
Domain Name
20What is the organization that deals with domain names (only highlevel such as tntech and .edu)
ICANN
21Mapping of domain names is maintained by
DNS (domain name system)
22Command to get ip address from domain name
nslookup
23Command that gets hostname of local host (other than just saying "localhost")
hostname
24A connection between a pair of processes is called
point-to-point
25A connection where data can flow in both directions at the same time is called
full duplex
26An end point of a connection
socket
27Contains an internet address and 16 bit integer port
socket address
28Port that is assigned automatically by the kernel when the client makes a connection request
emphemeral port
29Port that is permanently associated with a service
well-known port
30How to create a socket (server and client use this) #include <sys/types.h> and <sys/socket.h>
int sock = Socket(AF_INET, SOCK_STREAM, 0);
31What function attempts to establish an internet connection (client) #include <sys/types.h> and <sys/socket.h>
int connect(sock, &servAddr, sizeof(servAddr ));
32What function asks the kernel to associate the server's socket address with the socket descriptor? (server) #include <sys/types.h> and <sys/socket.h>
int bind(sock, (str sockaddr*) &serv_addr, sizeof(serv_addr));
33What function tells the OS that a server is listening on a socket and to start queing connections. (server) #include <sys/types.h> and <sys/socket.h>
listen(sock, queue_length);
34What function takes the queued connection request and fills in the socket address and returns a socket that can be used to communicate? (server) #include <sys/types.h> and <sys/socket.h>
newsock = accept(sock, &client_addr, sizeof(client_addr));
35TAKE THIS TIME TO MEMORIZE THIS CLIENT CODE:
int main() {
int sock;
struct sockaddr_in servAddr;
struct hostent *hp;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 {
error */
}
bzero((char *) &servAddr, sizeof(servAddr));
servAddr.sin_family = AF_INET;
hp = gethostbyname(”www.csc.tntech.edu”);
memcpy(&servAddr.sin_addr, hp->h_addr, hp->h_length);
servAddr.sin_port = htons(PORT);
if (connect(sock, &servAddr, sizeof(servAddr)) < 0) {
error */
}
if (send(sock, msg, strlen(msg), 0) < 0) { error */ }
close(sock);
return 0;
}
T
36MEMORIZE THIS SERVER CODE
int sockfd, newsockfd, clilen;
struct sockaddr_in cli_addr, serv_addr;
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
error */
}
memset((void *) &serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(PORT);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0) { error */ }
listen(sockfd, 5);
for (;;) {
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0) { error */ }
handleConnect(newsockfd);
}
T
37What opens a socket descriptor into a file stream
FILE *fp = fdopen(sock, "r+");
38What does HTTP stand for
Hypertext transfer protocol
39Typically with web servers, the response to a request is in this declaritive language that describes how something should look
HTML
40Java and c++ are ____ which means they have instructions on how to do something
imperative
41What is MIME type (ex: text./html or image/png)
multipurpose internet mail extensions
42Content that is simply fetched from disk and given to a client
static content
43Content that is an exectutable file that must be ran for the client
Dynamic content
44What does URL stand for?
Universal resource locator
45How do you format arguments sent by URL?
?key:value&key:value
46How do you write a http request?
GET [uniform resource identifier ex: /index.html] [HTTP Version]
HOST: localhost
47Whats the most recent Version of HTTP
HTTP/1.1
48What format is a HTTP response in?
version status-code status-message (HTTP/1.1 200 OK)
49200 = OK 301= Moved permentatnly 400= bad request 403=Forbidden 404=not found 501= not implemented 505= html not supported
T
50content-type: ___
MIME type
51content-length: ___
length in bytes
52How are spaces shown in arguments
%20
53- accessing slow I/O devices
- interacting with humans
- Reducing latency by defering work
- servicing multuple network clients
- computing in parallel on multicore machienes
uses of application level concurrency
54Each logical control flow is a process maintained by kernel. Harder to communicate between them (seperate address space). simplest way maintained through for and exec.
processes
55difficult to share state information, tend to be slower becayse of inter process communication and context switching
Cons of proccesses
56run in the context of a single process, scheduled by kernel, share virtual address space, unique thread ID, smaller context than processes,
threads
57void *thread(void *vargp);
int main() {
pthread_t tid;
pthread_create(&tid, NULL, thread, NULL);
pthread_join(tid, NULL);
exit(0);
}
void *thread(void *vargp) {
Thread routine */
printf("Hello, world!\n");
return NULL;
}
MEMORZE THIS
t
58what creates a thread
int pthread_create(threadid, NULL, threadfunction, pointer to any argument u pass);
59How to reap a thread
pthread_join(threadid, * return values of thread);
60how to detach a thread (make it release all memory instead of reaping)
int = pthread_detach(pthread_self())
61This is a form of concurrent programming where applications explicitly schedule their own logical
flows in the context of a single process.
Logical flows are modeled as state machines that the main program explicitly transitions from state to
state as a result of data arriving on file descriptors
I/O multiplexing
62 Each thread has its own:
• Thread context, including a unique integer thread ID (TID)
• Stack and stack pointer
• Program counter
• General-purpose registers, and
• Condition codes
T
63Each thread shares the context of the process its ran in
T
64Pthread_create returns
thread iD of the new thread
65Each thread share global variables
T
66When two threads are attempting to change a shared global variable at the same time
race condition
67the compiler will attempt to apply the operation in one atomic machine code instruciton
Atomic variables
68 the property that only one process is allowed in a critical section at a
time
Mutual exclusion
69pthread_mutex_t mut;
pthread_mutex_init(&mut, 0);
pthread_mutex_lock(&mut)
//do something with a shared variable
pthread_mutex_unlock(&mut);
MUTEX SYNTAX