Quiz 1 Flashcards
Socket lab, protocal layering (16 cards)
What is a socket?
- 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.
What is a socket descriptor?
- 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.
What are common socket APIs and their functions?
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 does a simple SERVER use socket APIs?
Create a socket: socket()
Bind to an address: bind()
Start listening: listen()
Accept connections: accept()
Send/receive data: send()
, recv()
How does a simple CLIENT use socket APIs?
Create a socket: socket()
Connect to a server: connect()
Send/receive data: send()
, recv()
What is a port?
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 do ports enable multiple processes to communicate?
- The OS maintains a mapping of port numbers to processes.
- Incoming packets are directed to the appropriate process based on the port number.
Why are certain ports reserved for specific services?
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.
Why can’t we use process IDs instead of ports?
- 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 does the OS buffer data for socket communication?
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
What is a protocol?
- A protocol is a set of rules for communication between computers.
- Defines message format, order, and semantics. Examples: TCP, UDP, HTTP, FTP.
What are the layers in the TCP/IP 5-layer model?
- Physical Layer: Transmits raw bits.
- Data Link Layer: Transfers frames over a link.
- Network Layer: Routes packets between networks.
- Transport Layer: Ensures reliable or fast delivery.
- Application Layer: Provides network services.
What are the benefits of protocol layering?
- Abstraction: Simplifies networking concepts.
- Modularity: Independent implementation of layers.
- Scalability: New technologies can be added easily.
- Reliability: Easier debugging and troubleshooting.
What is encapsulation and decapsulation?
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)
What are the layers in the OSI 7-layer model?
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.
What are the differences between the TCP/IP and OSI models?
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.