Quiz 1 Flashcards

Socket lab, protocal layering (16 cards)

1
Q

What is a socket?

A
  • A socket is an endpoint for communication between two machines.
  • combination of an IP address and a port number.
  • Used to establish a connection between a client and a server.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a socket descriptor?

A
  • integer that identifies a socket.
  • It is returned by the socket() function.
  • Used to refer to the socket in API calls.
  • Similar to a file descriptor in file I/O.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are common socket APIs and their functions?

A

socket(): Creates a socket.
bind(): Assigns an address to the socket.
listen(): Marks the socket as passive to accept connections.
accept(): Accepts an incoming connection.
connect(): Initiates a connection to a remote socket.
send(): Sends data over a socket from buffer.
recv(): Receives data from a socket into buffer

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

How does a simple SERVER use socket APIs?

A

Create a socket: socket()
Bind to an address: bind()
Start listening: listen()
Accept connections: accept()
Send/receive data: send(), recv()

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

How does a simple CLIENT use socket APIs?

A

Create a socket: socket()
Connect to a server: connect()
Send/receive data: send(), recv()

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

What is a port?

A

A port is a number that identifies a specific process or service on a host.
- Connections need the IP address of the dest. node, port number of the service of dest. node, and protocol used by the service

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

How do ports enable multiple processes to communicate?

A
  • The OS maintains a mapping of port numbers to processes.
  • Incoming packets are directed to the appropriate process based on the port number.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why are certain ports reserved for specific services?

A

Some ports (e.g., 22 for SSH, 80 for HTTP) are standardized for common services. Allows clients to always connect to the correct service without needing additional information.

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

Why can’t we use process IDs instead of ports?

A
  • Process IDs change with every restart. (not static)
  • Process IDs vary across different systems. (not the same across all nodes)
  • A process cannot have multiple process IDs, but it can listen on multiple ports.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does the OS buffer data for socket communication?

A

The OS uses buffers to store incoming and outgoing data.

Data moves between OS and application buffers when:
- when a server sends data, it is stored in the OS buffer and moved to the receive buffer of the client.
- the client then receives the data using a recv call.

How do you fill the client’s buffer?
- keep sending w/o receiving

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

What is a protocol?

A
  • A protocol is a set of rules for communication between computers.
  • Defines message format, order, and semantics. Examples: TCP, UDP, HTTP, FTP.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the layers in the TCP/IP 5-layer model?

A
  1. Physical Layer: Transmits raw bits.
  2. Data Link Layer: Transfers frames over a link.
  3. Network Layer: Routes packets between networks.
  4. Transport Layer: Ensures reliable or fast delivery.
  5. Application Layer: Provides network services.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the benefits of protocol layering?

A
  • Abstraction: Simplifies networking concepts.
  • Modularity: Independent implementation of layers.
  • Scalability: New technologies can be added easily.
  • Reliability: Easier debugging and troubleshooting.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is encapsulation and decapsulation?

A

Encapsulation: Each layer adds its own header as data moves down the stack.
(adding layers as we move down)

Decapsulation: Headers are removed as data moves up the stack.
(removing layers as we move up)

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

What are the layers in the OSI 7-layer model?

A

Physical: Transmits raw bits.
Data Link: Transfers frames.
Network: Routes packets.
Transport: Provides end-to-end data transfer.
Session: Manages communication sessions.
Presentation: Formats and encrypts data.
Application: Provides network services.

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

What are the differences between the TCP/IP and OSI models?

A

TCP/IP has 5 layers, OSI has 7 layers.
TCP/IP is practical and widely used, OSI is theoretical.
Error handling in TCP/IP is mainly in the Transport Layer, in OSI it’s spread across multiple layers.