[LINUX] BESS Development Memo # 01: BESS Installation and Basic Usage

Introduction

This is a guidebook on the development of BESS (Berkeley Extensible Software Switch). The official Wiki has only an English version and there is little content, so I will write this memo. This memo includes important content on the official Wiki, as well as understanding and discoveries when developing and reading the source code. If it helps someone, it will be fortunate.

Official Page-> BESS Official Wiki and Repo-> BESS Wiki

Development environment

Ubuntu 18.04 LTS recommended

We recommend installing Ubuntu on VMware. If you take advantage of the snapshot function and the system suffers irreparable damage, you can easily return to normal. Never install enough memory in the VM, 2-4GB is a guide.

Dependency installation

BESS requires the following soft packages:

sudo apt install make apt-transport-https ca-certificates g++ make pkg-config libunwind8-dev liblzma-dev zlib1g-dev libpcap-dev libssl-dev libnuma-dev git python python-pip python-scapy libgflags-dev libgoogle-glog-dev libgraph-easy-perl libgtest-dev libgrpc++-dev libprotobuf-dev libc-ares-dev libbenchmark-dev libgtest-dev protobuf-compiler-grpc
pip install --user protobuf grpcio scapy

Build

Run clones and scripts from Repo:

git clone https://github.com/NetSys/bess.git
cd bess/
sudo ./build.py

Build successful if the following output:

> sudo ./build.py
Configuring DPDK...
 - "Mellanox OFED" is not available. Disabling MLX4 and MLX5 PMDs...
Building DPDK...
Generating protobuf codes for pybess...
Building BESS daemon...
Building BESS kernel module (4.15.0-74-generic - running kernel) ...
Done.

Notes

  1. If you can't download the DPDK in the middle of the build, then manually download the output, unzip it in the folder `` `deps```, and build again.
  2. If you have rewritten the `core``` source code, it is recommended to delete the relevant * .o``` files before rebuilding.
  3. The source code in the folder `` `core / pb``` is generated by protobuf, so there is nothing before the build.
  4. All warnings are treated as errors. If there is an error, the build will definitely fail.
  5. Never install a huge page after a build. If the order is wrong, the next era may occur:
Log:
 make: Entering directory '/home/****/bess/core'
[CXX]       opts.o
[CXX]       worker.o
[CXX]       packet_pool.o
[CXX]       task.o
[CXX]       resume_hook.o
[CXX]       memory.o
[CXX]       dpdk.o
[CXX]       event.o
[CXX]       gate.o
[CXX]       port.o
[CXX]       main.o
[CXX]       debug.o
[CXX]       module_graph.o
[CXX]       bessctl.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
Error: bessctl.o
g++ -o bessctl.o -c bessctl.cc -std=c++17 -g3 -ggdb3 -march=native -isystem /home/****/bess/deps/dpdk-17.11/build/include -isystem /home/****/bess/core -isystem ./.. -isystem /home/****/bess/core/modules -D_GNU_SOURCE -Werror -Wall -Wextra -Wcast-align -Wno-error=deprecated-declarations -pthread -I/usr/include/x86_64-linux-gnu -fno-gnu-unique -O3 -DNDEBUG -MT bessctl.o -MMD -MP -MF .deps/bessctl.d
Makefile:439: recipe for target 'bessctl.o' failed
make: *** [bessctl.o] Error 1
make: Leaving directory '/home/****/bess/core'

Error has occured running command: make -j1 -C core

Installation of huge page

This installation is required for each reboot.

Execute the following command (command differs depending on the system):

# For single-node systems
sudo sysctl vm.nr_hugepages=1024

# For multi-node (NUMA) systems
echo 1024 | sudo tee /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 1024 | sudo tee /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages

Start BESS and run the test script

Run the following command

> sudo bessctl/bessctl
Type "help" for more information.
Connection to localhost:10514 failed
Perhaps bessd daemon is not running locally? Try "daemon start".
<disconnected> $

Then run `` `daemon start```:

Done.
localhost:10514 $

At this time BESS has already been started.

Let's run a test script:

$ run samples/acl

as a result:

Done.
localhost:10514 $

There is no output. The reason is that this script does not include any output commands. Enter the command `` `monitor pipeline``` and get the following output:

success.jpg

This is proof that the test script will run successfully.

Notes

I'm currently using Python3 for Linux, but I'm writing Python2 for BESS, so if I get the following error message:

Traceback (most recent call last):
  File "bessctl/bessctl", line 186, in <module>
    main()
  File "bessctl/bessctl", line 170, in main
    run_cli()
  File "bessctl/bessctl", line 159, in run_cli
    cli.loop()
  File "bessctl/bessctl", line 134, in loop
    super(BESSCLI, self).loop()
  File "/home/****/bess/bessctl/cli.py", line 528, in loop
    self.process_one_line()
  File "/home/****/bess/bessctl/cli.py", line 440, in process_one_line
    self.call_func(func, args)
  File "bessctl/bessctl", line 95, in call_func
    super(BESSCLI, self).call_func(func, args)
  File "/home/****/bess/bessctl/cli.py", line 411, in call_func
    func(*args)
  File "/home/****/bess/bessctl/commands.py", line 1720, in monitor_pipeline
    _monitor_pipeline(cli, 'pkts', '', graph_args=opts)
  File "/home/****/bess/bessctl/commands.py", line 1711, in _monitor_pipeline
    graph_args=graph_args))
  File "/home/****/bess/bessctl/commands.py", line 1389, in _draw_pipeline
    node_labels[gate.name]), file=f.stdin)
TypeError: a bytes-like object is required, not 'str

Run bessctl on Python2: python2 bessctl/bessctl

Continued

Next, I will introduce how to write a BESS script. You should also understand how to use the modules that BESS has.

Recommended Posts

BESS Development Memo # 01: BESS Installation and Basic Usage
Python installation and basic grammar
virtualenv Basic command usage memo
Python (Python 3.7.7) installation and basic grammar
Installation and easy usage of pytest
Elasticsearch installation and basic operation for ubuntu
How to install fabric and basic usage
Flask basic memo
RDKit usage memo
[Python] Chapter 01-02 About Python (Execution and installation of development environment)
python openCV installation (memo)
Python basic course (2 Python installation)
Numpy basic calculation memo
jupyter and pandas installation
Basic usage of flask-classy
Basic usage of Jinja2
Basic usage of SQLAlchemy
Python basic memo --Part 2
Basic Python command memo
Python basic grammar memo
Python basic memo --Part 1
[Memo] Django development environment
deap usage memo (OneMax)
RHCSA Test Preparation --Storage Function VDO Overview and Usage (Basic)