chapter 3 Flashcards

1
Q

how do computers communicate with each other?

A

by sending network messages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how do programs send / receive network messages?

A

through sockets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a socket?

A

is an endpoint in a 2 way communication link between 2 programs running on the same network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what are communication paradigms built from?

A

sockets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the 2 type of networks?

A

circuit switched and packet switched

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is circuit switching?

A

is a network that relies on a physical connection b/n 2 nodes for communication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what network guarantees constant QOS?

A

circuit switching

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is packet switching?

A

is a network that splits a message into packets to transmit them independently over a digital network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is internet protocol?

A

a unique address that identifies a device on a network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what do we mean when we say IP offers no guarantees?

A

packets may get:
- lost
- delivered twice
- corrupted
- delivered in wrong order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is UDP?

A

a transport protocol that does not guarantee the delivery or the ordered delivery of datagrams [ packets ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is TPC?

A

a bidirectional transport protocol that provides reliable [ data ] packet flow b/n devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how are network addresses represented in UNIX?

A

a generic struct sockaddr.
- for internet we use sockaddr_in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is a domain name?

A

a human readable IP address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is DNS?

A

a domain name service translates human readable domain names to machine readable IP address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how is domain name converted to IP?

A

using : gethostbyname ()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

list TCP based protocols?

A
  • TELNET
  • FTP
  • HTTP
  • SMTP
  • SSH
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

in sockets, what are the roles of:
- socket ()
- connect ()
- bind ()
- listen () and
- accept ()

A
  1. creates socket
  2. allows client to initiate a connection to server
  3. specifies socket id
  4. listen for a connection
  5. blocks process til incoming connection is received
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what are socket function calls in TCP client side?

A

socket, connect , write , read, close

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what are socket function calls in TCP server side?

A

socket, bind, listen, accept, read, write, read, close

21
Q

how are TCP sockets created by default?

A

as client socket

22
Q

which type of socket can’t receive incoming connection?

A

client socket

23
Q

which type of socket allocates resources for connections?

A

server socket

24
Q

how can we convert a client socket to a server socket?

A

by using listen( ) and specifying how many connections can be supported in parallel

25
Q

what arguments does the listen() function call take and what does it return?

A
  1. sockfd - socket discriptor
  2. backlog - size of buffer [ limits no of pending connections, not accepted conn]
    returns:
    - 0 for success and -1 for error
26
Q

what arguments does the connect() function call take and what does it return?

A
  1. sockfd - socket discriptor
  2. serv_addr - where to connect [ sockaddr_in ]
  3. addrlen - length of address
    returns
    - 0 for s -1 for f
27
Q

which socket function call binds client’s address to a random unused port?

A

connect( )

28
Q

what does accept( ) function call do when once a conn is received?

A
  • creates a dedicated socket for it
  • old socket goes back to waiting for other conns
29
Q

what arguments does the accept( ) function call take and what does it return?

A
  1. sockfd
  2. addr - address of client [ sockaddr_in ]
  3. addrlen
    returns:
    - descriptor of new socket or -1
30
Q

what arguments does the write( ) function call take and what does it return?

A
  1. sockfd
  2. buff - buffer to be sent
  3. count - buffer size
    returns:
    - no of bytes sent or -1
31
Q

what arguments does the read( ) function call take and what does it return?

A
  1. sockfd
  2. buff - buffer where to write the read data
  3. count - buffer size
    returns:
    - no of bytes read or -1
32
Q

which socket function call blocks process until data is received from socket?

A

read( )

33
Q

for what reason could a write( ) call send less bytes than requested?

A
  • due to limitations of kernel buffer, so always check return bytes and resend unsent data
34
Q

when does read( ) return 0?

A

when notifying end of file EOF

35
Q

what socket function calls block process when executing?

A

read and accept

36
Q

what is multiplexing?

A

is a way of sending multiple signals or streams of information through a socket [ communication link ]

37
Q

what are the methods to achieve multiplexing?

A
  1. using multiple processes
  2. using non blocking I/O
  3. using select( )
  4. using poll( )
38
Q

how does using multiple processes to achieve multiplexing work?

A

poorly, consumes resources and is hard to program

39
Q

how does using non-blocking I/O to achieve multiplexing work?

A

works for read( ) but not accept( )

40
Q

how does using select( ) monitor to achieve multiplexing work?

A

blocks the program until something [ read / write ] happens on the socket

41
Q

how does using poll( ) to achieve multiplexing work?

A

similarly to select( ), but provides additional info about streams

42
Q

list structures of a server?

A
  • iterative
  • 1 child / client
  • pre-forked
  • select loop
43
Q

briefly explain iterative server structure.

A
  • 1 req after another
  • long queue [ accept( ) ]
  • higher latency
  • low resource utilization
44
Q

briefly explain 1 child / client server structure.

A
  • new process created for every conn
  • concurrent handling of requests
  • not suitable for highly loaded servers
45
Q

which server structure is the most common among concurrent servers?

A

1 child / client

46
Q

briefly explain per-forked server structure.

A
  • server creates pool of processes
  • good for highly loaded servers
  • allows limitation on num of processes created
47
Q

how does the pre-forked server variant work?

A

with thread pools instead of process pools

48
Q

what is the downside of pre-forked servers?

A
  • accept( ) requires the use of synchronization
    lockmutex( ) -> accept( ) -> unlockmutext( )
49
Q

briefly explain select loop server structure.

A
  • difficult to do correctly
  • read more man idk