EXAM3

69 flashcardsby bauniee
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
client initiates, server responds
client-server model
2
network interface card. either wifi or ethernet
NIC
3
ethernet 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
4
A repeater. Will extend ethernet networks and broadcast anything that is sent to it right back out.
Hub
5
A 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
6
devices 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
7
protocol 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
8
protocol 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
9
Clients and Servers are Processes. NOT machines (hosts) T or F
T
10
Some wires and a small box
Ethernet segment
11
A chunk of bits that is sent from one host to another ON LAN
frame
12
Extends IP slightly just so that packets/datagrams can be sent from process to process instead of host to host
UDP (unrealiable Datagram Protocol)
13
Client calls Sockets interface, sockets calls kernel for TCP/IP stuff (NOT A QUESTION JUST TYPE T) this is how they are layered.
T
14
unsigned 32-bit integer. stored in the structure called in_addr which is in network byte order.
IP address
15
What is the function that converts byte order host to network short
htons()
16
What is this notation? (128.2.194.242)
dotted-decimal
17
You 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
18
What command shows the dotted decimal address of each NIC
ifconfig
19
a human-friendly representation of an IP address
Domain Name
20
What is the organization that deals with domain names (only highlevel such as tntech and .edu)
ICANN
21
Mapping of domain names is maintained by
DNS (domain name system)
22
Command to get ip address from domain name
nslookup
23
Command that gets hostname of local host (other than just saying "localhost")
hostname
24
A connection between a pair of processes is called
point-to-point
25
A connection where data can flow in both directions at the same time is called
full duplex
26
An end point of a connection
socket
27
Contains an internet address and 16 bit integer port
socket address
28
Port that is assigned automatically by the kernel when the client makes a connection request
emphemeral port
29
Port that is permanently associated with a service
well-known port
30
How 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);
31
What function attempts to establish an internet connection (client) #include <sys/types.h> and <sys/socket.h>
int connect(sock, &servAddr, sizeof(servAddr ));
32
What 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));
33
What 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);
34
What 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));
35
TAKE 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
36
MEMORIZE 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
37
What opens a socket descriptor into a file stream
FILE *fp = fdopen(sock, "r+");
38
What does HTTP stand for
Hypertext transfer protocol
39
Typically with web servers, the response to a request is in this declaritive language that describes how something should look
HTML
40
Java and c++ are ____ which means they have instructions on how to do something
imperative
41
What is MIME type (ex: text./html or image/png)
multipurpose internet mail extensions
42
Content that is simply fetched from disk and given to a client
static content
43
Content that is an exectutable file that must be ran for the client
Dynamic content
44
What does URL stand for?
Universal resource locator
45
How do you format arguments sent by URL?
?key:value&key:value
46
How do you write a http request?
GET [uniform resource identifier ex: /index.html] [HTTP Version]
HOST: localhost
47
Whats the most recent Version of HTTP
HTTP/1.1
48
What format is a HTTP response in?
version status-code status-message (HTTP/1.1 200 OK)
49
200 = OK 301= Moved permentatnly 400= bad request 403=Forbidden 404=not found 501= not implemented 505= html not supported
T
50
content-type: ___
MIME type
51
content-length: ___
length in bytes
52
How 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
54
Each 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
55
difficult to share state information, tend to be slower becayse of inter process communication and context switching
Cons of proccesses
56
run in the context of a single process, scheduled by kernel, share virtual address space, unique thread ID, smaller context than processes,
threads
57
void *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
58
what creates a thread
int pthread_create(threadid, NULL, threadfunction, pointer to any argument u pass);
59
How to reap a thread
pthread_join(threadid, * return values of thread);
60
how to detach a thread (make it release all memory instead of reaping)
int = pthread_detach(pthread_self())
61
This 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
63
Each thread shares the context of the process its ran in
T
64
Pthread_create returns
thread iD of the new thread
65
Each thread share global variables
T
66
When two threads are attempting to change a shared global variable at the same time
race condition
67
the 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
69
pthread_mutex_t mut;
pthread_mutex_init(&mut, 0);
pthread_mutex_lock(&mut)
//do something with a shared variable
pthread_mutex_unlock(&mut);
MUTEX SYNTAX
Study all 69 cards for free