CS 4410 Operating Systems Fall 2016
Due: Wednesday, November 2 @ 11:59 PM
In this project, I built a full networking stack using the C socket interface, and implemented the socket level calls in order to form point to point connections. Flooding (gossip) mechanism was implemented to flood messages to all other nodes in the network. A link-state routing protocol was applied to broadcast whatever data it received to all of its neighbors. A message sending interface that will allow nodes to send messages using the shortest path based on dijkstra's algorithm.
There are several distinct components to this project:
-
In
connect.c
main()
method,-
Create a non-blocking TCP socket using the
socket()
andfcntl()
system calls. -
Set the
SO_REUSEADDR
option on the socket using thesetsockopt()
-
Use
bind()
to bind the socket tobind_port
-
make a non-blocking socket in
try_connect
andserver_handler
where indicated. After this part, you should be able to compile and run your code. At the prompt, you should be able to connect two machines together using the connect command, which has the form:C192.168.2.248:54292
Achieved gossip messages to each other. Gossip messages have the form:
G<src_addr:port>/<counter>/<payload>\n
-
-
Implemented a flooding mechanism that will broadcast active connections every time connection state changes. Used the gossip mechanism mentioned in part 1. A gossip message has the form:
G<src_addr:port>/<counter>/<payload>\n
where the payload is
";<addr1:port1>;<addr2:port2>;<addr3:port3>...\n"
Essentially, the payload is a list of hosts to which you are connected.
There are two optimizations.
- Don't tell the person who sent you the message.
- Don't spread around messages you have seen already.
-
Implemented a link-state routing algorithm and a new 'send' message. The send message has a similar format as the gossip format. The main difference is that the address belongs to the destination, not the source, and the TTL is the maximum number of hops for this packet (TTL >= 0).
S<dst_addr:port>/<TTL>/<payload>\n
Remember, the link-state algorithm recomputes the shortest path every time it receives a new routing update, so the message will be sent through the current shortest path. When operating on a send message,
- If the send message belongs to you, then print out the payload.
- If the send message belongs to someone else, then decrement the TTL by 1. If TTL <= 0 then drop the message. Otherwise, forward it according to the shortest path.