Introduction to computer networks

You are to demonstrate discovery of a server using multicasting.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Both the client and server will agree on a port number (above 10000), which may be hard-coded into the programs.

The client will need to discover the address of the server, which might change.  The client is to send a message to a multicast address, and the server should respond point-to-point.

What is Multicast Discovery?

A client sends a message to an address which does not represent a
machine, but rather a service. The server listens to this address (in
addition to its own address) and is able to learn that a new client is
interested in communicating, and in particular it learns the IP address
of this client. The server responds directly to this IP address, and the
client is therefore able to learn the address of the server.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

The benefit of this scheme is that hard‐coded machine addresses are
not required. The multicast address can be hardcoded, but this address
will work on any network. The server may be using one IP address on
one day, and another machine may take over the next. Despite this,
the client does not need to be modified, since all servers listen to the
same multicast address.

How do you send a multicast message?

To send a multicast message you will address the message to an IP
address in the range reserved for multicasting. The choice of address is
up to you. Beware that it is possible (but unlikely) for another program to be using this address, so you should be prepared to change the
address in this case.

You will not be able to use a connection‐based session for multicast
discovery, since multicasting requires UDP (SOCK_DGRAM) and is
therefore connectionless. 

One caveat: if you are using a single machine for testing the client and
the server, you will need to allow your traffic to be “looped back” to the
host. Otherwise the outbound messages will be delivered to every
other machine in the group, but not the sending machine. Loopback is
enabled by default on some distributions, but if you need to explicitly
turn it on you will need to write:

char enable = 1;
setsockopt (socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof (loop);

How do you receive a multicast message?

Receiving multicast traffic is a little more work (perhaps 4 lines). The
lecture slides provided code which will join a multicast group, so you
should familiarize yourself with those examples. Specifically, you will
want to call setsockop() and add the multicast address to the list of
addresses the socket will listen to.

After the multicast group is joined, you may perform a recvfrom() and
wait for clients to connect. Note that this blocks the thread until a
datagram arrives.

Note that you will provide recvfrom() with a socket address and length
(uninitialized). These values will be filled in when a datagram arrives,
so you will know where the packet came from. This means that future
communication with the client can be directly to its address, as
opposed to continuing to use multicasting.

How do you unicast a response?

Unicasting is a just a fancy word to indicate that a packet is sent from
one machine to another (point to point) as opposed to multicasting or
broadcasting (one machine to many).

After a multicast message is received (only new clients should send
these), the server will need to send a UDP response back to the client in
order for the client to learn that server’s IP address. In a nutshell you
will call sendto() and provide the address of the client obtained from
the recvfrom().

What does the Client do when it receives a response?

Apart from the multicast discovery which was completed when the
server responded, all traffic should be TCP/IP. This means a connected
socket will need to be created between the server and the client. Once
the client learns the server’s IP address, it can open socket and connect
to the server’s address as we  have previously done.

When the server learns of a new connection attempt and accepts the
new connection, the server will gain a new connected socket. From
that point on, both the client and the server may communicate directly
using this socket pair.

Requirements

* The C language must be used
* UDP sockets must be used
* The client must initiate the “handshake” with a multicast message
* Port numbers may be hard-coded, as may a multicast address
* Aside from that, no address information may be hard-coded or input from the user
* The server should listen for multicast messages on the proper address
* The server should then initiate a unicast connection with the client
* The client should accept this connection
* The client will send 1 string to the server and then exit
* The server will receive the string, print the message along with the IP address of the client

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.

Order your essay today and save 30% with the discount code ESSAYHELP