Network Programming QBank
Network Programming QBank
Network Programming
Q1. [17fm, 18f, 19fm, 20f] Draw Various protocols in TCP/IO model?
Q2. [17fm, 18f, 19fm, 20f] Write the socket address data structure for IPv4
Q3. [17fm, 18f, 19fm, 20f] By what you can identify the connection between two hosts
We can identify the connection between two machines by IP address and port number
for each machine.
Q5. [17m, 18f, 19fm, 20f] Explain with drawing the socket functions for both TCP client
and server
● First, the server is started then sometime later, a client is started that connects
to the server
● We assume that the client sends a request to the server, the server process the
request, and the server sends a reply back to the client
● This continues until the client closes its end of the connection, which sends an
end-of-file notification to the server
● The server then closes its end of the connection and either terminate or waits
for a new client connection
Q6. [17fm, 18f, 19fm, 20f] Describe both little-endian byte order and big-endian byte
order
● With the low-order byte at the starting address, known as little-endian byte
order
● Or with the high-order byte at the starting address, known as big-endian byte
order
Q7. [18f, 19f] Describe by drawing the I/O models
Blocking I/O
Nonblocking I/O
■ When an I/O operation that I request cannot be completed without putting the
processes to sleep, do not put the process to sleep, but return an error instead.
I/O Multiplexing
● Call select or poll and block in one of these two system calls, instead of blocking
in the actual I/O system call
Asynchronous I/O
Q8. [17m, 18f, 19fm] What is the function of the following functions with write its
declarations:
★ inet_aton(...)
Converts an IPv4 address from dotted-decimal string “192.168.1.1” to its
32-bit network byte ordered binary value
// Declaration:
// Returns: 1 if string was valid, 0 on error
int inet_aton(const char *strptr, struct in_addr *addrptr);
● int_addr(...)
Converts an IPv4 address from 32-bit network byte ordered binary value to
its dotted-decimal string “192.168.1.1”
// Declaration:
// Returns: 32bit binary network byte ordered IPv4 address;
INADDR_NONE if error
in_addr_t inet_addr(const char *strptr);
● ntohs(...)
Convert from network byte order to host byte order
// return: value in host byte order
uint16_t ntohs(uint16_t net16bitvalue);
● htons(...)
Convert from host byte order to network byte order
// return: value in network byte order
uint16_t htons(uint16_t host16bitvalue);
Q9. [19fm, 20f] Explain by drawing the socket address structure passed from process to
The three functions bind, connect, and sendto pass a socket address structure from
the processed to the kernel.
One argument to these functions is the pointer to the socket address structure and
another argument is the integer size of the structure.
Since the kernel is passed both the pointer and the size of what the pointer points to, it
knows exactly how much data to copy from the process to the kernel.
Q10. [17f, 18f, 19fm, 20f] How to implement the client program and server program that
shown in the following figure
The above diagram is for an echo server that performs the following steps:
1. The client reads a line of text from its standard input and writes the line to the
server
2. The server reads the line from its network input and echoes the line back to the
client.
3. The client reads the echoed line and prints it on its standard output.
Q11. [18f] Explain I/O multiplexing (select function), and how to be used in the
connection of TCP? Give a simple example
Allows the process to instruct the kernel to wait for any one of multiple events to
occur and to wake up the process
Q12. [17f, 18f, 19f, 20f] In the TCP connection, the receiver has to know the number of
bytes which it receives, it is a problem of the synchronization, how to solve this
problem?
We determine a fixed size to the segment and add it to its TCP header so the receiver
is notified by the number of bytes that will be received.
A 32-bit sequence number is used to keep track of how much data is sent. THis
sequence number is included on each transmitted packet and acknowledged by the
opposite host as an acknowledgment number to inform the sending host that the
transmitted data was received successfully.
Q13. [17f, 18f, 19f, 20f] Design and implement a network chatting program with
exchanging files among a group of clients, How to think about it aby by using
drawing show the connectivity between the clients. Your answer has to consist of
functions prototype, the message format, write python code of both client and
server sides codes
Q14. [17fm, 18f, 19f] If you have a customer needs a program to use in his company that
have many branches in the world. Any branch needs to know the time of another
branches. Design and write the necessary code for that.
Q15. [17f, 18f, 19f, 20f] Design and implement a protocol in the application layer that
introduces one source to many destinations (one-to-many) service, this protocol is
called End-System Multicase (ESM). ESM is by nature centralized, everything
begins controlled by a single host, called Rendezvous Point (RP). Everything is
under control of RP. write python code of both Member and RP sides code.
RP:
● Knows members, their features, and communication costs between them.
● It’s responsible for overlay topology communication and its setup at each
member
UDP Tunnel:
● RP makes tunnels between nodes to make tree and create group of nodes
according to metrics between them
Evaluation Metrics
● Every node evaluate metrics between itself and other nodes and send them to
RP
● RP calculates the metrics between nodes and decides which nodes will connect
together and form a group of member od its neighnbors