CS 779/979- Networking Protocols (Spring 1999) Print your NAME:

advertisement

CS 779/979- Networking Protocols (Spring 1999)

Final Exam, Time 2 1/2 Hours, Open Book

Print your NAME:

The following is a simple Networking API (application programming interface). We will refer to this as the exam API.

Let IPP be a structure with two fields:

IPaddr (is either a unicast address, e.g., 128.82.4.67

 TCP-related API: or a multicast address, e.g., 224.2.2.2) and

Pno is a port number. s= createTCPsocket ();

TCPserver (s, port);

/* equivalent to bind(s, T), and listen(s,1), where T.IPPaddr = INADDR_ANY, T.Pno = port) */ sc= TCPaccept (s, from);

/* from is an IPP structure */

TCPclient (s, server

);

/* same as connect(s, server) and server is an IPP structure */

TCPsend (s, msg);

TCPrecv (s, msg);

 UDP-related API: s= createUDPsocket ();

UDPbind (s, port);

/* same as bind(s,T) where T.IPPaddr = INADDRANY, T.Pno = port) */

ReusePort (s)

/* let the port of socket s to be reused */

UDPsend (s, msg, to);

UDPrecv (s, msg, from);

/* to and from are IPP structures */

 Multicast-related API:

McastJoin (s, mcIP)

/* joins s to mulicast address mcIP, e.g., 224.2.2.2);

1

Q1: (10 Points)

Using the exam API, the following program is an implementation of group chat.

To chat a user may type: % chat 224.2.2.2 4560 main(argc, argv)

{

IPP chatIPP; mcIP= argv[1]; mcPort=argv[2]; chatIPP.IPaddr = mcIP; chatIPP.Pno = mcPort; s= createUDPsocket ();

UDPbind (s, mcPort);

McastJoin (s, mcIP);

If ( fork() == 0 ){

for(;;){

ReadKB (msg); /* read from Key Board */

UDPsend (s, msg, chatIPP);

}

}

UDPrecv (s, msg, from);

WriteTTY (msg); /* Write to TTY */

}

Fix this program so that it will be possible to run two instances of this program on the same host.

2

Q2: (25 Points)

Figure 1 shows two multicast domains. The hosts inside each domain are able to exchange multicast messages among each other . To enable multicast messages to flow between the two domains, an application-level tunnel is established between the two domains. At the end of each tunnel, there is a tunneling process T. T receives each multicast message sent by any chat process

C (similar to the one shown in Question1) in its domain and sends it as a unicast message to the tunneling process at the other end of the tunnel. A unicast message received by T from the tunnel is sent as a multicast message in its own domain.

Use the exam API to wrtite the code for T .

The syntax of using T is:

% T mcIP mcPort uIP uPort where mcIP and mcPort are the multicast group information and uIP and uPort are the other tunneling process unicast address information.

3

T's implementation using the exam API:

4

Q3: (10 Points)

Considering again Figure 1.

1.

What is the consequence of running T with mcPort = uPort ?.

2.

Is it possible for C s in one domain to know the IP addresses of C s in the other domain based on the received chat messages? Explain.

5

Q4: (20 Points)

Use the exam API to write an echo client and server. Each of the client and server create a udp and a TCP socket. The udp socket is used to exchange the echo data, while the TCP socket is used to exchange a heartbeat OOB data. Use the heartbeat routines developed in Chapter 21 (just call them with 1 probe/sec and 5 probes before giving up).

Echo Server's implementation using the exam API and the hearbeat function of chapter 21:

6

Echo Client's implementation using the exam API and the hearbeat function of chapter 21:

7

Q5: (25 Points)

Chapter 27 discussed many alternatives to server design.

Here is an outline for another alternative:

Parent thread: for (;;) {

Create a child thread;

Accept a client connection;

Inform the child thread to serve the client;

}

Child Thread:

Wait for orders to start serving the client;

Serve the client;

Terminate.

Let us call this server as a design alternative #9.

If the table in Figure 27.1 is expanded to include the performance of #9, then its the performance is expected to be between ____ and ____ seconds under Solaris.

8

#9 implementation using C (You may refer to the C code in Chapter 27).

9

Q6: (10 Points)

1.

In IPv4 the maximum payload packet size is _____ ,

while the maximum total packet size in IPv6 is _______.

2.

Compare IPv4 and IPv6 with respect to packet fragmentation policy and mechanism.

3.

How did IPv6 manage to quadruple the IP address length while only doubling the overall header length?

10

Download