diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..45ca5c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +# Install go + +all: install + +install-go: + wget -q -O - https://git.io/vQhTU | bash + +install: check-go + go install + @echo "" + @echo "Cli tool successfully installed, run 'go-ssip help' for more information" + @echo "If command 'go-ssip' is not found, make sure you have GOBIN in path" + +build: + go build -o ./bin/tajnik ./tajnik/main.go + +check-go: +ifeq (, $(shell which go 2> /dev/null)) + $(error No go cli tool found in PATH $(NEWLINE)\ + consider doing 'make install-go' or 'apt-get install golang-go' $(NEWLINE)\ + NOTE: doing 'make install-go' will automatically set needed env variables) +else + @echo "go compiler found, continuing" +endif + +define NEWLINE + + +endef \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index f51fdf3..0000000 --- a/README +++ /dev/null @@ -1,18 +0,0 @@ -Running performance test. This increases number of Nodes and connections in -simulation until simulation lasts for at least 10 seconds - --v is included for a more verbose test, exclude otherwise. - -``` -go test -bench=. -run=Bench -test.benchtime=10s -v ./... -``` - -Running all other tests: - -``` -go test -v ./... -``` - -Add `-count=1` flag to disable test caching - - diff --git a/README.md b/README.md new file mode 100644 index 0000000..8206153 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# Go-ssip + +## Installation +Clone this repo with `git clone git@github.com:vposloncec/go-ssip.git` + +* [**Go**](https://golang.org/cmd/go/) cli tool should be installed (run `go` to check). + + **If you have `go` you can skip this part.** + + The tool can be found and installed using your operating system's package manager or just + position yourself inside this repo and run: + ```shell + make install-go + # refresh your shell env variables with: + source ~/.(your_shell_rc_file) + + ``` + This script should install the tool and set needed env variables for all go-based tools to work. + +#### Install using +```shell +make +``` + +## Build without install +```shell +make build +``` +this will create an executable in `./bin` folder + + +## Documentation +`go-ssip help` +``` +Go-ssip creates a number of nodes that represent IoT devices +connected together in a P2P network. The nodes can have various attributes +they may or may not be public to other nodes. Propagation is done using gossip algorithm +with various parameters. + +Usage: + go-ssip [command] + +Available Commands: + completion Generate the autocompletion script for the specified shell + help Help about any command + run Start simulation + +Flags: + -l, --adjacency Print adjacency list + --config string config file (default is $HOME/.go-ssip.yaml) + -c, --connections int number of connections each node has to others (default 3) + -h, --help help for go-ssip + -n, --nodes int number of nodes to spawn (default 10) + -v, --verbose Debug output (verbose) + --version version for go-ssip + +Use "go-ssip [command] --help" for more information about a command. +``` + +## Running tests + +Running performance test. This increases number of Nodes and connections in +simulation until simulation lasts for at least 10 seconds + +-v is included for a more verbose test, exclude otherwise. + +``` +go test -bench=. -run=Bench -test.benchtime=10s -v ./... +``` + +Running all other tests: + +``` +go test -v ./... +``` + +Add `-count=1` flag to disable test caching + + diff --git a/base/node.go b/base/node.go index 375f709..02bdf4a 100644 --- a/base/node.go +++ b/base/node.go @@ -30,7 +30,7 @@ type Node struct { CpuScore int PackagesReceived int PackagesSent int - packagesDropped int + PackagesDropped int } type PacketLog struct { @@ -92,7 +92,7 @@ func (n *Node) sendAll(p *Packet) { if ShouldDropPacket(n.Reliability) { n.Log.Infof("Node %06d: Dropping packet send to node %v (reliability %v)", n.ID, neigbour.ID, n.Reliability) - n.packagesDropped++ + n.PackagesDropped++ continue }