The network layer for CP341: Computer Networking.
This C project establishes the network layer for the custom CP341 network.
- nic_net.c contains the network library and router.c contains the application interface.
This code depends on our nic_link library, which is available here. To compile and run the code, run the following commands:
git clone https://github.com/Jessicat-H/nic_link.git
git clone https://github.com/Jessicat-H/nic_net
cd nic_net
bash library_script.sh
./src/router <Unique ID>
Every node on the network must have a unique ID.
To write a networked application, include nic_app and use the exposed functions. Note: the router must be running on the computer in order to make network calls.
The code is intended to work on any number of nodes up to 18. To connect a node to the network, connect the xmit and recv ports on one port to an open recv and xmit (respectively) on an open port on a Pi that is already in the network, then run the executable. There is currently no command-line interface, but the nodes will send each other pings and the code can be changed to transmit messages between nodes.
Each message header looks like the following, with each section being a byte long:
| total length (not including the length) | source ID | number of hops so far | destination ID | message type |
Note, of course, that the link layer tacks on 2 synchronization bits before every message.
The following code was written by Jessica Hannebert, Dylan Chapell, and Tony Mastromarino.