### Computer Network and Security Exam Questions and Answers
### Computer Network and Security Exam Questions and Answers
#### Q1) b) A host was given the 192. 168.2.64 /25 IP address, indicate:
1. **Net mask in dotted decimal**: 255.255.255.128.
2. **Network address**: 192.168.2.0.
3. **Broadcast address**: 192.168.2.127.
4. **Total number of hosts**: 126 (2^7 - 2, as the first and last addresses
are reserved for network and broadcast addresses).
5. **First Usable Address**: 192.168.2.1.
6. **Last Usable Address**: 192.168.2.126.
7. **Subnetting**: This subnet mask divides the 192.168.2.0 network into
two subnets.
8. **Classful/less**: The /25 subnet mask is a classless addressing
technique (CIDR).
9. **Purpose**: Useful for creating smaller subnets to manage and
optimize IP address allocation.
### Q6) c) When web pages containing emails are sent out, they are
prefixed by MIME Header, why? Explain MIME Header.
7. **Security Policies**: These are rules and practices that dictate how an
organization manages, protects, and distributes sensitive information.
### Q7) b) Discuss the working of IPSec? What are the different security
services offered by IPSec?
1. **Active Attacks**:
- **Definition**: Attempts to alter system resources or affect their
operation.
- **Types**: Include masquerading, replay, message modification, and
denial-of-service attacks.
- **Detection**: Easier to detect due to their disruptive nature.
- **Example**: A hacker altering the content of a transmitted message.
2. **Passive Attacks**:
- **Definition**: Attempts to learn or make use of information from the
system without affecting system resources.
- **Types**: Include eavesdropping and traffic analysis.
- **Detection**: Harder to detect as they do not alter data or system
resources.
- **Example**: Sniffing network traffic to capture sensitive information.
3. **Use Cases**:
- **Symmetric**: Ideal for encrypting large amounts of data quickly,
such as file encryption and VPNs.
- **Asymmetric**: Used for secure key exchange, digital signatures,
and certificates.
7. **Session Keys**: Both client and server generate session keys from
the pre-master secret and other agreed-upon values, which will be used
to encrypt the session.
##############2nd oNE#############
2. **Packet Switching**:
- **Definition**: Data is broken into packets and each packet is routed
independently.
- **Connection Type**: No dedicated path; uses dynamic routing based
on current network conditions.
- **Resource Allocation**: Resources are used on a per-packet basis,
allowing for better utilization.
- **Example**: Internet data transmission.
- **Latency**: Can have variable latency due to differing packet routes
and network congestion.
- **Efficiency**: Highly efficient for bursty and variable data traffic.
3. **Comparison Points**:
- **Flexibility**: Packet switching is more flexible and can better handle
network failures and congestion.
- **Scalability**: Packet switching scales better with the increase in the
number of users and data volume.
- **Quality of Service**: Circuit switching can guarantee QoS more
easily as it has a reserved path, while packet switching relies on QoS
protocols and mechanisms.
2. **First IP Address**:
- **Network Address Calculation**: The first IP in the subnet is the
network address plus one.
- **Result**: 192.168.5.64 is the network address; the first usable IP is
192.168.5.65.
3. **Last IP Address**:
- **Broadcast Address Calculation**: The last IP in the subnet is the
broadcast address minus one.
- **Result**: 192.168.5.127 is the broadcast address; the last usable IP
is 192.168.5.126.
### Question 3
#### (a) What is a socket? What are different types of sockets? Explain
socket functions used in connectionless services with a diagram.
**Socket Definition**:
1. **Socket**: An endpoint for sending and receiving data across a
computer network.
**Types of Sockets**:
2. **Stream Sockets (SOCK_STREAM)**:
- Uses TCP for data transmission.
- Connection-oriented and reliable.
6. **Binding**: `bind()`
- Assigns a local address to the socket.
- Syntax: `bind(socket, address)`
7. **Sending Data**: `sendto()`
- Sends data to a specific address.
- Syntax: `sendto(socket, message, flags, dest_address)`
**Diagram**:
- Include a diagram showing the interaction of these functions for a
typical UDP communication.
2. **Congestion Avoidance**:
- Transition from exponential to linear growth once a threshold is
reached.
3. **Fast Retransmit**:
- Retransmits a packet immediately upon receiving three duplicate
ACKs.
4. **Fast Recovery**:
- Avoids slow start after packet loss.
- Reduces cwnd by half, then grows linearly.
6. **Congestion Detection**:
- Uses packet loss as a signal of congestion.
- Adjusts the congestion window to manage data flow.
#### (c) What is Quality of Service? Explain any two methods to improve
QoS.
4. **Priority Queuing**:
- Assigns priority levels to packets.
- Ensures higher-priority packets are transmitted first.
### Question 4
2. **Components**:
- **RTP Data Transfer Protocol**: Manages real-time data transfer.
- **RTCP (RTP Control Protocol)**: Monitors data delivery for QoS.
3. **Features**:
- Provides payload type identification.
- Supports sequence numbering and time-stamping.
4. **Header Format**:
- **Version**: 2 bits.
- **Padding**: 1 bit.
- **Extension**: 1 bit.
- **CSRC Count**: 4 bits.
- **Marker**: 1 bit.
- **Payload Type**: 7 bits.
- **Sequence Number**: 16 bits.
- **Timestamp**: 32 bits.
- **SSRC**: 32 bits.
- **CSRC**: 0 to 15 items, 32 bits each.
5. **Use Cases**:
- Video conferencing.
- Streaming media.
2. **Connection Management**:
- Establishes, maintains, and terminates connections.
- Uses TCP for reliable communication.
3. **Flow Control**:
- Manages data flow to prevent overwhelming the receiver.
- Uses mechanisms like sliding window protocol.
### Question 5
#### (a) What is HTTP? Explain HTTP request and reply messages.
3. **Example**:
- `GET /index.html HTTP/1.1`
5. **Example**:
- `HTTP/1.1 200 OK`
#### (b) Write short notes on SMTP and MIME.
### Question 6
#### (a) What is DHCP? Explain DHCP working with client state diagram.
**DHCP Working**:
2. **Steps**:
- **DHCPDISCOVER**: Client broadcasts a discover message.
- **DHCPOFFER**: Server responds with an offer.
- **DHCPREQUEST**: Client requests the offered address.
- **DHCPACK**: Server acknowledges and assigns the address.
**Webmail**:
3. **Purpose**: Accesses emails via a web browser.
4. **Features**:
- Provides email access from any device with internet.
- Offers user-friendly interfaces.
### Question 7
2. **Security Services**:
- **Confidentiality**: Ensures that the message is only accessible to
the intended recipient.
- **Integrity**: Ensures that the message is not altered.
**Security Policy**:
1. **Definition**: A set of rules and practices that specify how a system
or organization manages, protects, and distributes sensitive information.
**Security Mechanisms**:
2. **Examples**:
- **Encryption**: Protects data by converting it into a secure format.
- **Firewalls**: Prevent unauthorized access to or from a private
network.
- **Intrusion Detection Systems (IDS)**: Monitors network traffic for
suspicious activity.
### Question 8
2. **Components**:
- **Authentication Header (AH)**: Provides integrity and authentication.
- **Encapsulating Security Payload (ESP)**: Provides confidentiality,
integrity, and authentication.
3. **Modes**:
- **Transport Mode**: Encrypts only the payload of the IP packet.
- **Tunnel Mode**: Encrypts the entire IP packet.
4. **Protocols**:
- **IKE (Internet Key Exchange)**: Establishes a shared security policy
and authenticates keys.
### Question 1
### Question 2
#### (a) Draw and explain the header format of IPv4. [6]
#### (c) List and explain functions of the Network Layer. [6]
### Question 3
#### (a) Give the difference between TCP and UDP. [6]
1. **Connection**:
- **TCP**: Connection-oriented.
- **UDP**: Connectionless.
2. **Reliability**:
- **TCP**: Reliable delivery with error checking and acknowledgments.
- **UDP**: Unreliable, no guaranteed delivery.
3. **Ordering**:
- **TCP**: Ensures data is received in order.
- **UDP**: No ordering of data.
4. **Flow Control**:
- **TCP**: Provides flow control using windowing mechanisms.
- **UDP**: No flow control.
5. **Use Cases**:
- **TCP**: Suitable for applications requiring reliability (e.g., HTTP,
FTP).
- **UDP**: Suitable for applications needing speed and low overhead
(e.g., DNS, streaming).
6. **Overhead**:
- **TCP**: Higher overhead due to connection management.
- **UDP**: Lower overhead, simpler protocol.
### Question 4
2. **Connection Management**:
- Establishes, maintains, and terminates connections.
- Uses TCP for reliable communication.
3. **Flow Control**:
- Manages data flow to prevent sender from overwhelming the receiver.
- Implements mechanisms like sliding window protocol.
#### (c) What is a socket? What are different types of sockets? Explain
socket functions used in connection-oriented services with a diagram.
[6]
**Socket Definition**:
1. **Socket**: An endpoint for sending and receiving data across a
computer network.
**Types of Sockets**:
2. **
### Question 5
#### (a) What is DHCP? Explain DHCP working with a client state
diagram. [9]
### Question 6
#### (a) What is HTTP? Explain HTTP request and reply messages. [9]
**TELNET**:
1. **Purpose**: Provides a bidirectional interactive text-oriented
communication facility using a virtual terminal connection.
2. **Functionality**:
- Allows remote login and command execution.
- Operates on port 23.
3. **Security**: Unencrypted; replaced by SSH for secure connections.
**Webmail**:
1. **Purpose**: Allows users to access their email via a web browser.
2. **Functionality**:
- Provides email access from any internet-connected device.
- Supports sending, receiving, organizing emails.
3. **Popular Services**: Gmail, Yahoo Mail, Outlook.com.
### Question 7
1. **Key Used**:
- **Symmetric**: Same key for encryption and decryption.
- **Asymmetric**: Different keys for encryption (public key) and
decryption (private key).
2. **Speed**:
- **Symmetric**: Generally faster due to simpler algorithms.
- **Asymmetric**: Slower due to complex mathematical operations.
3. **Key Distribution**:
- **Symmetric**: Requires secure key distribution.
- **Asymmetric**: Public key can be openly shared.
4. **Security**:
- **Symmetric**: Less secure if the key is compromised.
- **Asymmetric**: More secure due to the use of two keys.
5. **Use Cases**:
- **Symmetric**: Bulk data encryption, file encryption.
- **Asymmetric**: Digital signatures, secure key exchange.
6. **Examples**:
- **Symmetric**: AES, DES.
- **Asymmetric**: RSA, ECC.
**Firewalls**:
1. **Purpose**: Protects a network by controlling incoming and outgoing
network traffic based on predetermined security rules.
2. **Types**:
- **Packet-Filtering Firewalls**: Inspect packets and allow/deny based
on source/destination IP, ports.
- **Stateful Inspection Firewalls**: Monitor the state of active
connections and make decisions based on the state and context of the
traffic.
- **Proxy Firewalls**: Act as an intermediary between users and the
internet.
3. **Deployment**: Can be hardware, software, or both.
4. **Functions**:
- Blocks unauthorized access.
- Monitors and logs traffic.
- Prevents cyber attacks like DoS, DDoS.
5. **Use Cases**: Enterprise networks, home networks, individual
devices.
### Question 8
######################4th ##################
### Question 1
**Circuit Switching:**
1. Establishes a dedicated communication path between two devices for
the duration of the session.
2. Resources are reserved for the entire connection, ensuring consistent
quality of service.
3. Commonly used in traditional telephone networks (PSTN).
4. The path is fixed, and no other data can use the reserved resources
during the session.
5. Efficient for continuous, steady data transmission, such as voice
calls.
6. Can result in resource wastage if the connection is idle.
7. Examples include ISDN and traditional voice circuits.
8. Connection setup and teardown time can add latency.
9. Not suitable for bursty or intermittent data transmission, as resources
are not dynamically allocated.
**Message Switching:**
1. Messages are routed in their entirety from source to destination, with
intermediate nodes storing and forwarding the entire message.
2. No dedicated path is established; each message is treated
independently.
3. Messages can be of varying lengths and are stored in queues at each
node if the next link is busy.
4. Suitable for applications that can tolerate delays, such as email and
file transfer.
5. Can lead to high storage requirements at intermediate nodes.
6. Offers flexibility and efficiency for non-real-time communications.
7. Intermediate nodes can implement error checking and retransmission.
8. No resource reservation means potentially variable delivery times.
9. Can handle large, complex data transfers without needing a constant
connection.
**Packet Switching:**
1. Data is divided into small packets, each of which is routed
independently through the network.
2. No dedicated path; packets may take different routes to the
destination.
3. Used in modern IP networks, including the Internet.
4. Efficient use of network resources as packets share the same paths.
5. Suitable for both bursty and continuous data transmission.
6. Allows for dynamic rerouting of packets in case of network
congestion or failure.
7. Packets are reassembled in order at the destination.
8. Can introduce variable latency and packet loss.
9. Protocols like TCP/IP ensure reliable delivery and error recovery.
### Question 2
2. **First IP Address:**
- Network address calculation: 192.168.5.51 AND 255.255.255.192 =
192.168.5.0
- First usable address is one more than the network address:
192.168.5.1
3. **Last IP Address:**
- Broadcast address calculation: 192.168.5.51 OR (NOT
255.255.255.192) = 192.168.5.63
- Last usable address is one less than the broadcast address:
192.168.5.62
### Question 3
URG, ACK, PSH, RST, SYN, FIN) that manage the state of the
connection.
8. **Window Size (16 bits):** Indicates the size of the sender's receive
window (flow control).
9. **Checksum (16 bits):** Used for error-checking of the header and
data.
10. **Urgent Pointer (16 bits):** Points to the end of urgent data if the
URG flag is set.
11. **Options (variable length):** May contain additional options, such as
Maximum Segment Size (MSS), timestamp, and others.
12. **Padding (variable length):** Ensures that the TCP header is a
multiple of 32 bits.
2. **Data Transfer:**
- Data is sent and acknowledged using sequence and acknowledgment
numbers.
- Flow control and congestion control mechanisms ensure efficient
and reliable transfer.
3. **Connection Termination (Four-Way Handshake):**
- **Step 1:** Client sends FIN (finish) packet to server.
- **Step 2:** Server acknowledges with an ACK packet.
- **Step 3:** Server sends its own FIN packet.
- **Step 4:** Client acknowledges with an ACK packet, closing the
connection.
### Question 4
2. **Persistent HTTP:**
- A single TCP connection is maintained for multiple HTTP
requests/responses.
- Reduces latency by reusing the same connection.
- More efficient, especially for web pages with multiple resources.
- HTTP/1.1 uses persistent connections by default.
- Can handle pipelining, where multiple requests are sent without
waiting for corresponding responses.
### Question 5
### Question 6