---
# System prepended metadata

title: Modify EmPOWER Agent
tags: [EmPOWER]

---

---
tags: EmPOWER
---
# Modify EmPOWER Agent

簡單來說，修改的步驟為：
1. 修改 `empower-lvap-agent` 裡面的任何檔案，可以透過 `make` 來確保沒有 compile error
2. 將 `empower-lvap-agent` push 到 remote 端
3. `git log ` 取得 `empower-lvap-agent` 的 git log hash value
4. 將 `empower-lvap-agent` 新的 git log hash value 更新到 `empower-openwrt-packages` 裡面的 makefile
5. 將 `empower-openwrt-packages` push 到 remote 端
6. 在 `empower-openwrt` 裡面 `./scripts/feeds update empower` 來更新
7. `make package/empower-lvap-agent/compile -j4` ，只需要重新編譯 empower click file
8. 將編譯好的 `click` 執行檔傳到 AP 裡面

## 主要修改部份 (與 EmPOWER 比較)

* Minstrel
    * 功能：決定封包傳送的 bitrate，以及從 hardware 接收 feedback，得知封包傳送的結果(幾次失敗，成功與否)
    * 主要修改：收集與計算 average bitrate, retransmission ratio
* empowerqosmanager
    * 功能：EmPOWER agent 的中繼站，有一個 queue 來暫存封包。決定接下來要傳哪一個 lvap 的封包。實做完 airtime fairness 之後，每個 lvap 有自己的 queue
    * 主要修改：airtime fairness。紀錄 lvap 的封包有被 transmitted, queued or dropped，推算 traffic demand
* empowerlvapmanager
    * 功能：與 controller 的溝通
    * 主要修改：定期回報 lvap 的 average bitrate, retransmission ratio

## Step 0 - Change Feeds path

Change the file `feeds.conf.default` in `empower-openwrt`.
The src-git of empower package should be 
`src-git empower git@github.com:chunyu618/empower-openwrt-packages.git`

## Step 1 - Clone the Repo

To modify the elemwnts in `empower-lvap-agent` repo, the first step is to clone following two repo into your own github

* [`empower-lvap-agent`](https://github.com/5g-empower/empower-lvap-agent)
* [`empower-openwrt-packages`](https://github.com/5g-empower/empower-openwrt-packages)



Now, you can clone it into you PC or workspace. Then, you need to modify the Makefile in `empower-openwrt-packages/empower-lvap-agent/`. The variables need to be changed are following:

* `PKG_SOURCE_URL`: change the value to your repo url on the github
* `PKG_REV`: change the value to the commit log hash of the version your need

```
#
# Copyright (C) 2019 Roberto Riggio
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=empower-lvap-agent
PKG_VERSION:=20220307
PKG_RELEASE:=1
# This variable
PKG_REV:=32c18594a4f942f016069373ab73eca12e4c5a62

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
# This variable
PKG_SOURCE_URL:=git@github.com:chunyu618/empower-lvap-agent.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_PROTO:=git

```

## Step 2 - Modify something in the element

After modifying something in the `element` folder, you may want to compile it locally before `git push` it in order to be sure there is no compile error. Back to `empower-lvap-agent/`, run `./configure --enable-all-elements` if you have nerve done it. Then `make install` to compile it. As long as there is no compile error, you can git push you changes into github.

Next, we need to update the commit log value in `empower-openwrt-packages`. Change directory into `empower-openwrt-packages/empower-lvap-agent` and modify the value `PKG_REV` in Makefile to the commlit log that you just commit in `empower-lvap-agent`

Don't forget to git push `empower-openwrt-packages`.

## Step 3 - Re-compile 

After you git push these $2$ repo, you change directory into `empower-openwrt`, now we update and re-make the empower package.

```shell=
$ ./scripts/feeds update empower
$ make package/empower-lvap-agent/compile -j4
```


After that, there should be a `click` executable file in `build_dir/target-mips_24kc_musl/empower-lvap-agent-xxxxxxxx/ipkg-mips_24kc/empower-lvap-agent/usr/bin/`. Here the `xxxxxxxx` corresponds to the `PKG_VERSION` in the above Makefile. Copy it to the router, located at `/usr/bin`, then reboot router or just run `/etc/init.d/empower restart`, the change you made should be effect. 
Run `/etc/init.d/empower stop` to stop the original `click` running.