Skip to content

YingdaDu/link-state-routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS 4410 Operating Systems Fall 2016


10-P3: Full Stack Networking

Due: Wednesday, November 2 @ 11:59 PM

Overview

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.

The Details

There are several distinct components to this project:

  1. In connect.c main() method,

    • Create a non-blocking TCP socket using the socket() and fcntl() system calls.

    • Set the SO_REUSEADDR option on the socket using the setsockopt()

    • Use bind() to bind the socket to bind_port

    • make a non-blocking socket in try_connect and server_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

  2. 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.

    1. Don't tell the person who sent you the message.
    2. Don't spread around messages you have seen already.
  3. 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,

    1. If the send message belongs to you, then print out the payload.
    2. 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.

Releases

No releases published

Packages

No packages published