5.1.
Time Zone Support
This project operates on the local system time and does not implement any explicit
time zone management. Time-related information like log entries is printed in real-time
based on the system clock. Since there's no data storage or timestamp comparison
across systems, no additional time zone handling is needed. If extended to distributed
systems, time zone normalization would become important.
5.2. Language Support
The interface uses English, with static prompts in printf() and messages logged in
English for clarity. There is no internationalization (i18n) or localization (l10n) system in
place. The netstat command also returns output in English by default, which is suitable
for command-line users and network administrators.
5.3. User Desktop Requirements
Only a basic Linux terminal is needed. The user runs the client executable and selects
options using standard input. The terminal must support standard I/O and display
output from TCP socket communication. No GUI or additional software (like X Server or
GTK) is required.
5.4.1. Deployment Considerations
The server runs as a multithreaded C program on a Linux machine. It must be compiled
with gcc using the -pthread flag for thread support. Deployment requires permissions to
open a port (9999), and optionally sudo access to install net-tools if netstat is missing.
5.4.2. Application Server Disk Space
Disk usage is minimal, under 1 MB including binaries and the user credential file.
Runtime data is kept in RAM. Output from netstat is not logged to disk; instead, it's sent
over the socket to the client in real-time, reducing storage overhead.
5.4.3. Database Server Disk Space
No actual DBMS is used. A flat file users.txt serves as the authentication
store, holding
username|password pairs. It is read at startup using fscanf() and stored in a struct
array. This avoids the need for MySQL or SQLite while keeping credentials easily
editable.
5.4.4. Integration Requirements
The server integrates directly with the operating system using the shell and standard C
libraries. No third-party APIs or web services are called. Integration is done via:
- popen() to execute shell commands like netstat.
- send() and recv() to handle socket communication.
- fscanf() for file I/O authentication.
5.4.5. Jobs
No scheduled tasks or CRON jobs are used. Every action is event-driven: the server
responds only when a client connects and sends a choice. This makes the system
lightweight and suitable for lab and classroom use.
5.4.6. Network
TCP sockets are created using the Berkeley socket API (socket, bind, listen, accept,
connect). The server listens on port 9999 using IPv4 (AF_INET) and accepts connections
with SOCK_STREAM semantics for reliable data delivery. The client sends a numeric
choice (int), which the server interprets to run a netstat command.
5.4.7. Others (Authentication)
Authentication is implemented using a struct array of User (containing username and
password). The function authenticate() checks against the hardcoded admin credentials
(admin, admin123) or the loaded users.txt list. This creates two roles: Admin (can run
both server/client) and Normal user (client-only).
5.5.1. Operating System
Linux is the primary OS. This project depends on POSIX-compliant system calls for
file access,
sockets, and threads. Linux comes with built-in support for gcc, net-tools, and process
management, making it ideal for system-level development. Distributions like Ubuntu
or Debian are recommended.
5.5.2. POSIX
POSIX is a standard that ensures compatibility between Unix-like systems. This project
uses POSIX APIs such as socket(), bind(), listen(), accept(), fork(), and popen(). These
calls allow the program to work seamlessly across various Linux distros. For instance,
popen() is used to run netstat commands and read their output like a file stream.
5.5.3. GCC
The project is compiled using gcc, a powerful compiler for C/C++ programs on Linux.
The -pthread flag is essential to link the POSIX thread library. Compilation commands:
gcc -o server server.c -
pthread gcc -o client client.c
gcc -o login Login.c
gcc provides warnings, optimizations, and debugging info to build a reliable executable.
5.5.4. Pthreads
POSIX Threads (Pthreads) allow concurrent handling of multiple clients. The server uses
pthread_create() to launch a new thread for every incoming connection. This allows the
server to remain responsive and scalable. Each thread is detached after serving a
client, avoiding memory leaks.
5.5.5. Netstat
netstat (Network Statistics) is a CLI utility that displays network connections, routing
tables, and interface stats. The server executes:
netstat -t for TCP
netstat -u for UDP
netstat -tu for all
It's invoked via:
FILE *fp = popen(command, "r");
and read line-by-line using fgets().
5.5.6. Popen()
popen() opens a process by creating a pipe and invoking a shell. In this project, it is
used to run the netstat command and capture its output. The output is sent to the client
in real-time, giving the appearance of a remote network scanner.
5.5.7. Socket Programming
The project uses TCP sockets (SOCK_STREAM) for reliable communication. socket(),
bind(), and listen() on the server side prepare the system to accept connections. The
client uses connect() to reach the server. The communication is binary (int for choice,
char arrays for output).
5.5.8. File I/O (Authentication)
The login system reads user credentials using:
fscanf(file, "%49[^|]|%49s\n", username, password);
The use of a delimiter (|) allows easy splitting of fields. The login logic separates Admin
and Normal users, and behavior is routed accordingly using system("./server") or
system("./client").
5.5.9. System() Function
The system() function runs a shell command. In Login.c, it is used to invoke other
executables:
system("./server");
system("./client");
This allows the login program to act as a launcher for other components.
Architecture Flowchart
Execution Flowchart (pthread flow)