Skip to content

Commit

Permalink
Add Makefile and README install instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
vposloncec committed Jan 31, 2024
1 parent cc5b12e commit 240f7f9
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 20 deletions.
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 0 additions & 18 deletions README

This file was deleted.

79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Go-ssip

## Installation
Clone this repo with `git clone [email protected]: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


4 changes: 2 additions & 2 deletions base/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Node struct {
CpuScore int
PackagesReceived int
PackagesSent int
packagesDropped int
PackagesDropped int
}

type PacketLog struct {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 240f7f9

Please sign in to comment.