Skip to content
David Josephs edited this page Nov 6, 2015 · 19 revisions

User Manual

Setting Up A Go Workspace

The first thing you need to do is install golang. A guide for this can be found here: Getting Started With Go

Once you complete this tutorial, you should have a workspace directory for go, pointed to by $GOPATH. This directory should contain a src/, bin/, and pkg/. If they are not there, create them. Once golang is installed and you have this directory, with $GOPATH pointing to it, and $GOBIN pointing to the /bin directory within it, you are ready for the next step.

Acquiring This Code

Golang has a command-line tool 'go'. To acquire the necessary code, you're going to need to use go get which downloads and install packages and their dependencies. You'll need to run three of these:

go get github.com/garyburd/redigo/redis

go get github.com/gyuho/goraph/graph

go get github.com/Grissess/sdnd16/

Once you have done this, you should have the necessary code in your /src directory.

Building The Project

At this point, we need to build the code. You could build any of the test cases you wanted, but this guide will show building the client. You can do this by running

go install src/github.com/Grissess/sdnd16/client/client.go

Setting Up A Redis Database

Download and compile and install Redis. Use redis-server to start a local instance of the redis server, and use redis-cli to talk to the redis server using the command line. To check if the redis server is working by typing redis-cli ping. It will return PONG if it is running. To save your data base use redis-cli shutdown to save the server.

To create a server to be accessed not only no your machine follow these steps. Make sure that the redis server and cli exicutables are in /usr/local/bin . Also create a directory to store your config files and data, /etc/redis /var/redis. Copy the init script that you'll find in the Redis distribution under the utils directory into /etc/init.d. We suggest calling it with the name of the port where you are running this instance of Redis. Make sure to modify the REDISPORT according to the port you are using. The pid file path and the configuration file name depend on the port number.

Run this command to copy a template file into /etc/redis sudo cp redis.conf /etc/redis/6379.conf. Create a directory inside /var/redis that will work as data and working directory for your working Redis instance name it the name of your port.

Edit the configuration file, making sure to perform the following changes: Set daemonize to yes (by default it is set to no). Set the pidfile to /var/run/redis_6379.pid (modify the port if needed). Change the port accordingly. In our example it is not needed as the default port is already 6379. Set your preferred loglevel. Set the logfile to /var/log/redis_6379.log Set the dir to /var/redis/6379 (very important step!) Finally add the new Redis init script to all the default runlevels using the following command: sudo update-rc.d redis_6379 defaults You are done! Now you can try running your instance with: /etc/init.d/redis_6379 start

This was created by using the official redis quick start guide which can be found at this link, http://redis.io/topics/quickstart.

Writing A Topology File

To use the client, you're going to need a topology file. You can write one of these very easily yourself. Simply write a text file with the following form describing each edge:src dst cost where src is the label for the source node, dst is the label for the destination (both strings of any kind), and cost is a positive integer representing a cost, with tabs separating them all.

Running the Client

To run the built client, run ./bin/client

You will be given two options: store or grab. Storing is the process of putting a topology into the database, grab allows you to get information from a topology you have stored in the database.

When storing, you be asked for a file name for a topology file, a name for this database record, and a ip address and port number for a database. To store a topology, enter the name of the file containing it, give a memorable name, and the ip address and port of your redis database (on localhost if that's where your database is).

When grabbing, you will be asked for the name of a topology record in the database, and the address/port number for the database it is stored on. After this, you will be asked for the labels of two nodes, and you will then be responded to with the shortest path between these two nodes, and the total cost. This process will then loop until Ctrl+C'd.

Notes And Troubleshooting.

Further functionality will be added soon, and this document will be updated. If you need any help of any kind, please email fultonms@clarkson.edu, or submit an issue on this repository.

Clone this wiki locally