Skip to content

Commit

Permalink
[New NF] Simple Forward with Token Bucket NF
Browse files Browse the repository at this point in the history
New Simple Forward Token Bucket Rate Limiter NF that simulates a queue with a token bucket and forwards packets to a specific destination.  The NF forwards packets based on a user specified rate (-R) and depth (-D). 

Commit log:

* Add skeleton for NF

* Add main NF logic

* Add simple_fwd_tb NF to list

* Update copyrights

* Add go.sh

* Add README.md

* Minor changes

* Change file name

* Update burst parameter in dequeue function

* Update processing batch size

* Fix style errors

* Fix style errors

* Fix style issues

* Advanced rings fix

* Change Mbps to MBps

* Add warning and check for small values of tb_depth
  • Loading branch information
rohit-mp authored May 29, 2020
1 parent 18b2f58 commit ec2b2fa
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $(error "Please define RTE_SDK environment variable")
endif

# To add new examples, append the directory name to this variable
examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall
examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall simple_fwd_tb

ifeq ($(NDPI_HOME),)
$(warning "Skipping ndpi_stats NF as NDPI_HOME is not set")
Expand Down
2 changes: 2 additions & 0 deletions examples/simple_fwd_tb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
simple_fwd_tb/
build/
68 changes: 68 additions & 0 deletions examples/simple_fwd_tb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# openNetVM
# https://github.com/sdnfv/openNetVM
#
# BSD LICENSE
#
# Copyright(c)
# 2015-2017 George Washington University
# 2015-2017 University of California Riverside
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif

RTE_TARGET ?= x86_64-native-linuxapp-gcc

# Default target, can be overriden by command line or environment
include $(RTE_SDK)/mk/rte.vars.mk

# binary name
APP = simple_fwd_tb

# all source are stored in SRCS-y
SRCS-y := forward_tb.c

# OpenNetVM path
ONVM= $(SRCDIR)/../../onvm

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/lib
LDFLAGS += $(ONVM)/onvm_nflib/$(RTE_TARGET)/libonvm.a
LDFLAGS += $(ONVM)/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm

# workaround for a gcc bug with noreturn attribute
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
CFLAGS_main.o += -Wno-return-type
endif

include $(RTE_SDK)/mk/rte.extapp.mk
36 changes: 36 additions & 0 deletions examples/simple_fwd_tb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Simple Forward with Token Bucket
==
Example NF that simulates a queue with a token bucket and forwards packets to a specific destination.

Compilation and Execution
--

```
cd examples
make
cd simple_fwd_tb
```
```
./go.sh SERVICE_ID -d DST [-p PRINT_DELAY] [-D TOKEN_BUCKET_DEPTH] [-R TOKEN_BUCKET_RATE]
OR
./go.sh -F CONFIG_FILE -- -- -d DST [-p PRINT_DELAY] [-D TOKEN_BUCKET_DEPTH] [-R TOKEN_BUCKET_RATE]
OR
sudo ./build/simple_fwd_tb -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- -d DST [-p PRINT_DELAY] [-D TOKEN_BUCKET_DEPTH] [-R TOKEN_BUCKET_RATE]
```

App Specific Arguments
--
- `-d <dst>`: destination service ID to foward to
- `-p <print_delay>`: number of packets between each print, e.g. `-p 1` prints every packets.
- `-D <token_bucket_depth>`: depth of token bucket (in bytes)
- `-R <token_bucket_rate>`: rate of token regeneration (in MBps)

Config File Support
--
This NF supports the NF generating arguments from a config file. For additional reading, see [Examples.md](../../docs/Examples.md)

See `../example_config.json` for all possible options that can be set.
Loading

0 comments on commit ec2b2fa

Please sign in to comment.