Router (single-thread)
A demonstration of a simple IPv4 router.
- GitHub Link: https://github.com/packetcord/packetcord.io/tree/main/apps/l3_router
- Topology File: topology_examples/l3_router.json
Topology diagram
Steps
Build the project (all examples)
Note: You may need to uncomment the static binding inside the CMakeLists.txt file of the examples:
# Link against cord-flow
target_link_libraries(l3_router_app
PRIVATE
cord_flow
-static # Adding for 'compatibility' when running on Alpile (musl)
)
cd packetcord.io
mkdir build
cd build
cmake .. --fresh
make
Start the topology
Load the exampe topology project file. Then Validate, Generate and Launch the topology.
Inside the shell of Forwarder
./l3_router_app
Result
Open the shells of Node A and Node B. Try to ping each other (192.168.6.100 and 192.168.7.100).
PING 192.168.7.100 (192.168.7.100): 56 data bytes
64 bytes from 192.168.7.100: seq=0 ttl=63 time=0.065 ms
64 bytes from 192.168.7.100: seq=1 ttl=63 time=0.066 ms
64 bytes from 192.168.7.100: seq=2 ttl=63 time=0.101 ms
64 bytes from 192.168.7.100: seq=3 ttl=63 time=0.112 ms
--- 192.168.7.100 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.065/0.086/0.112 ms
Let's also run iperf3 between the other two nodes:
Inside the shell of iperf3 Server
iperf3 -s
Inside the shell of iperf3 Client
iperf3 -c 192.168.8.100
Connecting to host 192.168.8.100, port 5201
[ 5] local 192.168.5.100 port 36344 connected to 192.168.8.100 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 191 MBytes 1.60 Gbits/sec 988 100 KBytes
[ 5] 1.00-2.00 sec 212 MBytes 1.77 Gbits/sec 1312 97.6 KBytes
[ 5] 2.00-3.00 sec 225 MBytes 1.89 Gbits/sec 1469 100 KBytes
[ 5] 3.00-4.00 sec 223 MBytes 1.87 Gbits/sec 1357 100 KBytes
[ 5] 4.00-5.00 sec 220 MBytes 1.84 Gbits/sec 1321 96.2 KBytes
[ 5] 5.00-6.00 sec 224 MBytes 1.88 Gbits/sec 1469 103 KBytes
[ 5] 6.00-7.00 sec 224 MBytes 1.88 Gbits/sec 1374 100 KBytes
[ 5] 7.00-8.00 sec 221 MBytes 1.85 Gbits/sec 1394 147 KBytes
[ 5] 8.00-9.00 sec 224 MBytes 1.88 Gbits/sec 1439 100 KBytes
[ 5] 9.00-10.00 sec 224 MBytes 1.88 Gbits/sec 1443 144 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 2.13 GBytes 1.83 Gbits/sec 13566 sender
[ 5] 0.00-10.00 sec 2.13 GBytes 1.83 Gbits/sec receiver
Note: You may also run some packet capture (tshark, tcpdump) on the nodes to verify that traffic is forwarded properly between the specified source and destination.
Terminate
Use the Destroy button to terminate the emulation.