📝 Accounting management in networking (9 MCQs)
Tracking Network Resource Consumption and Use
Accounting management records how network resources are used by users, devices, departments or services. It can track connection time, transferred data, sessions, service consumption and allocated capacity. Organizations use these records for internal cost allocation, usage reporting, policy enforcement and capacity planning. The exact measurements depend on the service and the organization’s accounting requirements. Clear attribution makes the resulting reports useful for audits and planning.
Usage Records, Identities and Measurement Periods
Accounting systems associate usage measurements with an identifiable account, device, service or organizational unit. Records may contain start and stop times, input and output byte counts, session identifiers and service details. Collection can use device counters, access servers, application logs or a dedicated accounting protocol, then consolidate records for reporting.
Collecting and Summarizing Accountable Activity
A system begins a usage record when a session starts and updates or closes it when the session ends. Network equipment may report counters and session attributes to a central collector. The collector validates the records, associates them with the correct account, calculates totals for a period and stores results for audit or billing.
Example: Measuring Data Use by a Subscriber
A provider records that subscriber A transferred 2.5 GB during a billing period and used a connection for 18 hours. The accounting system associates the counters with the subscriber's authenticated session, applies the provider's stated usage policy, and produces a usage summary. The figures describe measured consumption, not the subscriber's identity verification.
Accounting Data for Planning and Service Policies
Accounting records complement authentication and authorization in access networks. Authentication identifies the account starting a session, authorization determines which service is allowed, and accounting records what resources were consumed. Aggregated records can also help estimate peak demand, detect unusual usage and plan capacity without confusing usage measurement with performance measurement.
Distinguishing Accounting from Authentication
'Accounting means financial accounting only' is too narrow because it also includes non-billing usage records. 'Authentication measures resource use' is incorrect; it verifies identity. 'A byte counter reveals which application sent every byte' is false unless the system collects additional flow or application-level information. Accounting identifies resource consumption; it does not by itself establish who controls an account.
Usage Records and Accounting Scenarios in Exams
Be able to distinguish accounting from authentication and authorization, identify common session attributes, and explain how counters become usage summaries. Scenario questions may ask which record fields support billing, how user sessions are associated with measurements, or why accounting data alone cannot prove application identity or network quality. Always check the measurement period and identity linked to each record.
Network Usage and Accounting Terms
- Accounting record - A stored description of resource usage.
- Session - A period of associated network activity.
- Counter - A value tracking accumulated activity.
- Usage total - A summarized resource consumption measurement.
- Collector - A system receiving accounting records.
- Audit trail - Records supporting later review of activity.
📝 All Accounting management in networking MCQs
Q1. In the code snippet, if the call to accept() fails, which of the following statements best describes the subsequent program behavior?
📖 Explanation: When accept() returns a negative value, the conditional block executes perror, which writes an error to stderr, then exit(1) is called. This causes immediate termination of the process, preventing any further execution of the receive or send loops. Hence the server does not continue listening after a failed accept.
Q2. What does the recv() function return when data is successfully received?
📖 Explanation: recv() returns the count of bytes placed into the supplied buffer for the current call. This value is stored in variable n and used to update pointers and lengths. A return of zero signals a graceful shutdown by the peer, while negative values indicate errors.
Q3. Which statement correctly contrasts TCP and UDP usage in an echo‑server context as illustrated by the code?
📖 Explanation: TCP’s stream‑oriented nature mandates a three‑way handshake (socket, bind, listen, accept) and ensures ordered, reliable delivery, which matches the echo server’s design. UDP, being datagram‑oriented, lacks these guarantees and would require different handling (e.g., recvfrom) without the accept/listen sequence.
Q4. To allow the server to handle multiple simultaneous clients using fork(), which modification is most appropriate?
📖 Explanation: Forking after a successful accept creates a child process dedicated to a single client, allowing the parent to return to accept new connections. The child handles the recv‑send sequence and then exits, while the parent continues listening, achieving concurrent client handling without altering the existing logic flow.
Q5. What is the effect of the statement ptr += n within the receive loop?
📖 Explanation: The expression ptr += n increments the pointer by the number of bytes just received, positioning it at the next free location in the buffer. This ensures that each subsequent recv() call appends data rather than overwriting earlier bytes, maintaining a continuous stream of received data.
Q6. If the variable maxLen is not reset after each recv() call, what risk does the code incur?
📖 Explanation: maxLen represents the remaining space in the buffer. Failing to decrement it appropriately (or resetting it) can cause recv() to think there is more space than actually exists, leading to writes past the buffer’s end. This overflow can corrupt memory, cause crashes, or expose security vulnerabilities.
Q7. Which approach best integrates a logging mechanism that records each client’s IP address and byte count without disrupting the existing flow?
📖 Explanation: Embedding a struct that captures the client’s sockaddr_in data (obtained from accept()) and the total bytes transferred (len) allows precise logging. Writing this information to a file in the child process after the echo completes ensures that each connection’s details are recorded atomically, preserving the server’s responsiveness.
Q8. If the send() call were placed before the receive loop, using the current value of len, what would most likely occur?
📖 Explanation: Placing send() before any data is received means len remains at its initial value (typically zero). The call would attempt to transmit zero bytes, which may be interpreted as a closed connection or cause the client to wait indefinitely for data that never arrives, disrupting the echo protocol.
Q9. How does calling close(s) differ from shutdown(s, SHUT_RDWR) in the context of this echo server?
📖 Explanation: close(s) releases the file descriptor but does not explicitly signal the peer about the termination of communication. shutdown(s, SHUT_RDWR) sends a FIN to the peer, indicating that no further sends or receives will occur, which can be useful for graceful shutdowns in a protocol‑aware server.