# SRv4 **Repository Path**: yyl-nudt/srv4 ## Basic Information - **Project Name**: SRv4 - **Description**: SRv4 is an implementation of Segment Routing for IPv4 in Linux kernel using eBPF technology. - **Primary Language**: C - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-05-16 - **Last Updated**: 2023-09-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Segment Routing for IPv4 (SRv4) # 1. Introduction  SRv4 is an implementation of Segment Routing for IPv4 in Linux kernel using eBPF technology.SRv4 designed an packet header for IPv4 to carry information of Segment Routing witch named SRH4(Segment Routing Header for IPv4). The format of SRH4 is as Fig1.  SRv4 program consists 2 modules, the kernel module and the user module. The kernel module runs in the kernel space and is used to process the packets received by the interface the kernel module loaded in. The user module runs in the user space and is an user-interface used to set or list segment routing parameters. The format of encapsulation header is as Fig2.  In the source node, the SRv4 kernel module inserts the segment routing information to SRH4 and encapsulate the SRH4 to IPv4 packets. In the transit node, the SRv4 kernel module modifies the SRH4 and update the destination IP of IPv4 packets, then forward the packets according to the new destination IP. In the sink node, the SRv4 kernel module decapsulate the SRH4, recover the original message, and sends packets to destination.

Fig1. Format of SRH4

Fig2. Format of Encapsulation Header
# 2.How to start? It is needed to compile and install libbpf first. ## 2.1. Compile ```shell $cd Srv4 $make ``` ## 2.2. Load Kernel Module Program "srv4_loader" is used to load or unload the kernel module. For example: * Load the SRv4 kernel module to interface "ifname" in "S"(SKB) mode. `$./srv4_loader -d ifname -S` * Unload the SRv4 kernel module loaded in interface "ifname". `$./srv4_loader -d ifname -S -U` * More information to: `$./srv4_loader -h` ## 2.3. Set SR Parameters Program "srv4_user" is used to set or list the segment routing parameters. For example: * Add an END sid to interface "ifname" `$./srv4_user -D ifname -s 202.197.1.11 END` * Add a path to interface "ifname" `$./srv4_user -D ifname -p 202.197.4.17,202.197.5.18` * More information to: `$./srv4_user -h` ## 2.4. List SR Parameters Program "srv4_user" is used to set or list the segment routing parameters. For example: * List the sid of interface "ifname" `$./srv4_user -D ifname -l s` * List the path of interface "ifname" `$./srv4_user -D ifname -l p` * More information to: `$./srv4_user -h` # 3. Test We use 5 nodes to deploy the SRv4 program and test the functions and performance. ## 3.1 Network Topology The test network topology is as Fig3.

Fig3. Network Topology
## 3.2 Config and Load The IPs and the SIDs of the interfaces in Fig3 are as table:
Tab1 IP and SID Config
|Interface Name|IPv4 Address|Encap SID|END SID|DEncap SID| |:------------:|:----------:|:-------:|:-----:|:--------:| |Client-enp6s0 |202.197.1.10|\ |\ |\ | |S1-enp7s0 |202.197.2.10|\ |\ |\ | |S2-enp6s0 |202.197.2.11|\ |\ |\ | |Server-enp6s0 |202.197.3.10|\ |\ |\ | |S1-enp6s0 |202.197.1.11|202.197.1.16|202.197.1.17|202.197.1.18| |S1-enp8s0 |202.197.4.10|202.197.4.19|202.197.4.20|202.197.4.21| |S2-enp7s0 |202.197.3.11|202.197.3.16|202.197.3.17|202.197.3.18| |S2-enp8s0 |202.197.5.10|202.197.5.16|202.197.5.17|202.197.5.18| |S3-enp6s0 |202.197.4.11|202.197.4.16|202.197.4.17|202.197.4.18| |S3-enp7s0 |202.197.5.11|202.197.5.19|202.197.5.20|202.197.5.21|
* In Client `$./confignet` * In Server `$./copnfignet` * In S1 `$./reload-srv4` `$./addsid` * In S2 `$./reload-srv4` `$./addsid` * In S3 `$./reload-srv4` `$./addsid` ## 3.2 Test Result The performance of SRv4 is tested using iperf and the test result is as Fig4.

Fig4. Performance of SRv4 and Linux ipforward
## REFERENCES [1] https://github.com/libbpf/libbpf [2] https://github.com/xdp-project/xdp-tutorial [3] https://github.com/feiskyer/ebpf-apps