<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Siddharth Tyagi on Medium]]></title>
        <description><![CDATA[Stories by Siddharth Tyagi on Medium]]></description>
        <link>https://medium.com/@mailsiddharthtyagi?source=rss-3131e6dd3372------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*N0QwItmog8YKH3fm</url>
            <title>Stories by Siddharth Tyagi on Medium</title>
            <link>https://medium.com/@mailsiddharthtyagi?source=rss-3131e6dd3372------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:47:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mailsiddharthtyagi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Source-side Path Selection with SRv6 NEXT-CSID in Containerlab]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/source-side-path-selection-with-srv6-next-csid-in-containerlab-0f5589cbd829?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f5589cbd829</guid>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[srv6]]></category>
            <category><![CDATA[containerlab]]></category>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Sun, 06 Dec 2026 18:15:09 GMT</pubDate>
            <atom:updated>2026-12-06T18:15:09.764Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In my <a href="https://medium.com/@mailsiddharthtyagi/exploring-srv6-usid-and-next-csid-in-containerlab-e2d33aa01c19?sharedUserId=mailsiddharthtyagi">previous</a> article, I explored SRv6 uSID and NEXT-CSID in Containerlab, demonstrating how a packet can be steered through a predefined network path using a sequence of uSIDs encoded in the IPv6 destination address.</p><p>In this part, I extend that setup to understand <strong>source-side path selection.</strong></p><p>Instead of using only one predefined path, GPU1 will be able to select between two available paths to reach GPU2:</p><ul><li>Path A: GPU1 -&gt; Leaf1 -&gt; Spine1 -&gt; Leaf2 -&gt; GPU2</li><li>Path B: GPU1 -&gt; Leaf1 -&gt; Spine2 -&gt; Leaf2 -&gt; GPU2</li></ul><p>The path selection is performed at the source by changing the uSID sequence in the IPv6 destination address. Scapy is used to emulate this source-side functionality.</p><h3>1. Lab topology</h3><p>The topology consists of two GPU endpoints, two leaf switches and two spine switches. The two paths share the same source and destination endpoints but use different spine switches. Topology details were already described <a href="https://medium.com/@mailsiddharthtyagi/exploring-srv6-usid-and-next-csid-in-containerlab-e2d33aa01c19?sharedUserId=mailsiddharthtyagi">here</a>.</p><h3>2. Understanding source-side path selection</h3><p>In this lab, each path is represented by a different uSID sequence.</p><p><strong>Path A — via Spine1</strong></p><pre>5f00:0:100:500:200:300::</pre><p><strong>Path B — via Spine2</strong></p><pre>5f00:0:100:600:200:300::</pre><p>The difference between the two paths is the Spine uSID:</p><ul><li><em>500</em> selects Spine1.</li><li><em>600</em> selects Spine2.</li></ul><p>The uSID sequence identifies the forwarding instructions encoded in the IPv6 destination address. The source (GPU1) selects the desired path by choosing the corresponding destination address when constructing the packet. As the packet traverses the network, each router processes its local uSID using NEXT-CSID and advances to the next instruction. In summary, by changing the IPv6 destination address in the Scapy packet, we can direct traffic through either path.</p><h3>3. Configure Path A through Spine1</h3><p>The existing Path B configuration <a href="https://medium.com/@mailsiddharthtyagi/exploring-srv6-usid-and-next-csid-in-containerlab-e2d33aa01c19?sharedUserId=mailsiddharthtyagi">remains</a> as is. We add the necessary NEXT-CSID forwarding configuration for Spine1 (mere, additive config). Leaf1 forwards the Spine1 uSID towards Spine1, while Spine1 processes its local uSID and forwards the packet towards Leaf2.</p><p><strong>3.1 Configure the Path A routes<br></strong>The Path A uSID sequence is:</p><pre>5f00:0:100:500:200:300::</pre><p>Now, we need three forwarding actions:</p><ol><li><strong>Leaf1:</strong> After processing its uSID (100), forward the packet to Spine1.</li><li><strong>Spine1:</strong> Process its uSID (500) using NEXT-CSID, then forward to Leaf2.</li><li><strong>Leaf2:</strong> Reuse its existing (200) SID processing and final forwarding toward GPU2.</li></ol><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Leaf1: forward the Spine1 uSID toward Spine1<br>docker exec clab-srv6-ai-leaf1 ip -6 route replace 5f00:0:500::/48 via 2001:db8:11:1::2 dev eth2 table 90<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Spine1: enable SRv6 and IPv6 forwarding<br>docker exec clab-srv6-ai-spine1 sysctl -w net.ipv6.conf.all.forwarding=1<br>docker exec clab-srv6-ai-spine1 sysctl -w net.ipv6.conf.all.seg6_enabled=1<br>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Spine1: create the dummy interface<br>docker exec clab-srv6-ai-spine1 sh -c &#39;ip link add dum0 type dummy 2&gt;/dev/null || true; ip link set dum0 up&#39;<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Spine1: add policy rule for table 90, if not already present<br>docker exec clab-srv6-ai-spine1 sh -c &#39;ip -6 rule show | grep -q &quot;999:.*lookup 90&quot; || ip -6 rule add priority 999 table 90&#39;<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Spine1: process its local uSID using NEXT-CSID<br>docker exec clab-srv6-ai-spine1 ip -6 route replace 5f00:0:500::/48 encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 table 90<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Spine1: forward the next uSID toward Leaf2<br>docker exec clab-srv6-ai-spine1 ip -6 route replace 5f00:0:200::/48 via 2001:db8:21:1::1 dev eth2 table 90<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><p><strong>3.2 What this configuration does</strong></p><pre>Node: Leaf1  | Destination prefix: 5f00:0:500::/48 -&gt; Action: Forward to Spine1<br>Node: Spine1 | Destination prefix: 5f00:0:500::/48 -&gt; Action: Execute NEXT-CSID End<br>Node: Spine1 | Destination prefix: 5f00:0:200::/48 -&gt; Action: Forward to Leaf2</pre><p>The existing Leaf2 configuration handles the remaining 200 and 300 uSIDs, so we do not need to modify it.</p><p><strong>3.3 Verify Path A configuration</strong></p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ for node in leaf1 spine1 leaf2; do<br>  echo<br>  echo &quot;========== $node ==========&quot;<br>  docker exec clab-srv6-ai-$node ip -6 rule show<br>  docker exec clab-srv6-ai-$node ip -6 route show table 90<br>done<br><br>========== leaf1 ==========<br>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main<br>5f00:0:100::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br>5f00:0:500::/48 via 2001:db8:11:1::2 dev eth2 metric 1024 pref medium<br>5f00:0:600::/48 via 2001:db8:12:1::2 dev eth3 metric 1024 pref medium<br><br>========== spine1 ==========<br>0:      from all lookup local<br>999:    from all lookup 90<br>32766:  from all lookup main<br>5f00:0:200::/48 via 2001:db8:21:1::1 dev eth2 metric 1024 pref medium<br>5f00:0:500::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br><br>========== leaf2 ==========<br>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main<br>2001:db8:10:2::/64 via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>5f00:0:200::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br>5f00:0:300::/48 via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><p>The output confirms that the required routes are installed.<br>- Leaf1: Has the 100 local SID and forwarding routes for both Spine1 (500) and Spine2 (600).<br>- Spine1: Has the 500 local SID using NEXT-CSID and forwards the next 200 uSID toward Leaf2.<br>- Leaf2: Retains its existing 200 local SID and forwarding route for the final 300 uSID.<br>The policy rules are also present. Path B remains configured (already shown in previous lab)</p><h3>4. Generate packets using Scapy</h3><p>Scapy runs on GPU1 and constructs an IPv6/UDP packet. For Path A, the IPv6 destination is:</p><pre>5f00:0:100:500:200:300::</pre><p>For Path B, the IPv6 destination is:</p><pre>5f00:0:100:600:200:300::</pre><p>Changing this destination allows us to select the forwarding path at the source. Now, given that we are using Conatinerlab, this is a software emulation of source-side path selection, not an implementation of automatic path selection in a physical SmartNIC.</p><p>So,for this lab, we use Scapy’s sendp() function to transmit an Ethernet frame directly through GPU1’s data-plane interface (eth1).</p><pre>from scapy.all import Ether, IPv6, UDP, Raw, sendp, getmacbyip6<br><br>dstmac = getmacbyip6(&#39;2001:db8:10:1::1&#39;)<br><br>pkt = (<br>    Ether(dst=dstmac) /<br>    IPv6(<br>        src=&#39;2001:db8:10:1::2&#39;,<br>        dst=&#39;5f00:0:100:500:200:300::&#39;<br>    ) /<br>    UDP(sport=50001, dport=9000) /<br>    Raw(load=b&#39;SRv6-NEXT-CSID-Path-A-Proof&#39;)<br>)<br><br>sendp(pkt, iface=&#39;eth1&#39;, count=1, verbose=False)</pre><p>What this script does:<br>1. Resolves Leaf1’s MAC address, which is the next-hop destination.<br>2. Constructs an Ethernet frame containing an IPv6 packet.<br>3. Encodes the Path A uSID sequence in the IPv6 destination address.<br>4. Adds a UDP header and a small payload.<br>5. Sends one Ethernet frame through GPU1’s eth1 interface.</p><h3>5. Verify Forwarding Using tcpdump</h3><p>To verify the packet forwarding path, we started tcpdump on eight data-plane interfaces across GPU1, Leaf1, Spine1, Leaf2, and GPU2.</p><p>We sent one IPv6/UDP packet from GPU1 using the Path A uSID sequence:</p><pre>5f00:0:100:500:200:300::</pre><p>The packet captures showed the IPv6 destination address changing as it passed through the SRv6 nodes:</p><ul><li>Leaf1 processed its uSID and advanced the destination to 5f00:0:500:200:300::</li><li>Spine1 processed its uSID and advanced the destination to 5f00:0:200:300::</li><li>Leaf2 processed its uSID and advanced the destination to 5f00:0:300::</li><li>GPU2 received the packet with the final destination address<br>5f00:0:300:: aka , the final uSID remaining in the IPv6 destination address after NEXT-CSID processing at Leaf1, Spine1, and Leaf2.</li></ul><p>All eight capture points observed the packet with the expected destination address. This confirms that the packet followed Path A through Spine1 and that NEXT-CSID processing worked as expected in our Containerlab setup.</p><p>Packet captured on GPU1 eth1 showing the original Path A uSID sequence before entering the SRv6 network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COBncTNB7-AvDvNi0jWF2A.png" /></figure><p>Packet captured on Spine1 eth2 showing the updated IPv6 destination after NEXT-CSID processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hDHcA9uS06RS_yt1kKmMOA.png" /></figure><p>Packet captured on GPU2 eth1 showing the final SRv6 SID after NEXT-CSID processing along Path A.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0bIFU5GQHkVSevw4ILbdA.png" /></figure><h3>6. Result</h3><p>We successfully tested both paths:</p><ul><li>Path A through Spine1.</li><li>Path B through Spine2.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qn1VU3rccZgpgXWxyDQWUw.png" /></figure><p>Packet captures confirmed that changing the uSID sequence at GPU1 selects the path, and both paths successfully delivered packets to GPU2.<br>In the next part, we will explore how to distribute packets across both SRv6 paths using Scapy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f5589cbd829" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring SRv6 uSID and NEXT-CSID in Containerlab]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/exploring-srv6-usid-and-next-csid-in-containerlab-e2d33aa01c19?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d33aa01c19</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[srv6]]></category>
            <category><![CDATA[containerlab]]></category>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 16:56:48 GMT</pubDate>
            <atom:updated>2026-11-18T16:56:48.715Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently built a basic SRv6 fabric using Containerlab (<a href="https://medium.com/@mailsiddharthtyagi/building-srv6-fabric-in-containerlab-e497925d8681">previous lab</a>) and wanted to extend it to explore SRv6 in AI backend networks.</p><p>In this lab, I use Linux SRv6 and Python/Scapy to demonstrate how uSID and NEXT-CSID encode a selected path in the IPv6 destination address, enabling hop-by-hop traffic steering from one GPU endpoint to another.</p><h3><strong>Lab topology</strong></h3><p>I’m starting with a simple topology:</p><ul><li>2 Leaf switches</li><li>2 Spine switches</li><li>2 GPU worker containers</li></ul><p>GPU1 connects to Leaf1, and GPU2 connects to Leaf2. Both Leafs connect to both Spines, providing two paths between the GPU endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4ajWIkJeoxJCTkVjzSCkQ.png" /></figure><h3>Environment</h3><ul><li>Ubuntu VM</li><li>Containerlab 0.83.0</li><li>Linux kernel 7.0</li><li>Docker 29.1.3</li></ul><h3>Containerlab deployment</h3><p>Created the project directory:</p><pre>mkdir -p ~/srv6-ai-backend/{configs,scripts,captures}<br>cd ~/srv6-ai-backend</pre><p>Created the Containerlab topology:</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ cat topology.clab.yml<br>name: srv6-ai<br><br>topology:<br>  nodes:<br>    leaf1:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br>    leaf2:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br>    spine1:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br>    spine2:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br>    gpu1:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br>    gpu2:<br>      kind: linux<br>      image: ghcr.io/srl-labs/network-multitool<br><br>  links:<br>    - endpoints: [&quot;gpu1:eth1&quot;, &quot;leaf1:eth1&quot;]<br>    - endpoints: [&quot;gpu2:eth1&quot;, &quot;leaf2:eth1&quot;]<br>    - endpoints: [&quot;leaf1:eth2&quot;, &quot;spine1:eth1&quot;]<br>    - endpoints: [&quot;leaf1:eth3&quot;, &quot;spine2:eth1&quot;]<br>    - endpoints: [&quot;leaf2:eth2&quot;, &quot;spine1:eth2&quot;]<br>    - endpoints: [&quot;leaf2:eth3&quot;, &quot;spine2:eth2&quot;]<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><p>Validated and deployed the topology:</p><pre>containerlab deploy --topo topology.clab.yml --dry-run<br>containerlab deploy --topo topology.clab.yml</pre><p>All six containers started successfully, and the six network links were created.</p><h3>Enabling SRv6</h3><p>Enabled IPv6 forwarding and SRv6 processing on the four router containers:</p><pre>for n in leaf1 leaf2 spine1 spine2; do<br>  docker exec -u 0 clab-srv6-ai-$n sh -c &#39;<br>    sysctl -w net.ipv6.conf.all.forwarding=1<br>    sysctl -w net.ipv6.conf.default.forwarding=1<br>    sysctl -w net.ipv6.conf.all.seg6_enabled=1<br>    sysctl -w net.ipv6.conf.default.seg6_enabled=1<br>  &#39;<br>done</pre><p>Verified that IPv6 forwarding and SRv6 were enabled.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ for n in leaf1 leaf2 spine1 spine2; do<br>  echo &quot;=== $n ===&quot;<br>  docker exec clab-srv6-ai-$n sh -c &#39;<br>    sysctl net.ipv6.conf.all.forwarding<br>    sysctl net.ipv6.conf.all.seg6_enabled<br>  &#39;<br>done<br>=== leaf1 ===<br>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1<br>=== leaf2 ===<br>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1<br>=== spine1 ===<br>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1<br>=== spine2 ===<br>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><h3>NEXT-CSID support</h3><p>Linux kernel support for NEXT-CSID configuration is important for our lab because GPU1 will encode the selected path as a sequence of uSIDs in the IPv6 destination address. As the packet travels, each router advances to the next uSID using NEXT-CSID and forwards it towards the next hop.</p><p>A test SRv6 local route was successfully installed on the Ubuntu host:</p><pre>sudo ip -6 route add 2001:db8:100::1/128 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev lo</pre><p>Breaking down the above command</p><pre>ip -6 route add → Add an IPv6 route<br>2001:db8:100::1/128 → The specific IPv6 address this route matches<br>encap seg6local → Configure a local SRv6 processing action<br>action End → Apply SRv6 End behavior<br>flavors next-csid → Enable NEXT-CSID processing<br>lblen 32 → Locator Block length is 32 bits<br>nflen 16 → Locator-Node Function length is 16 bits<br>dev lo → Associate the route with the loopback interface</pre><p>Suppose a packet arrives with the destination address 2001:db8:100:200:300::<br>1. The router matches the prefix 2001:db8:100:: (Locator Block 2001:db8 + its own Node ID 100).<br>2. Because of flavors next-csid, it drops 100 and shifts 200 and 300 to the left, rewriting the destination IPv6 address to 2001:db8:200:300::.<br>3. It then looks up 2001:db8:200:: in its routing table and forwards the packet toward the next router (200).</p><p>On a side note, the route was accepted and displayed by ip -6 route show. This confirms that the kernel accepts the configuration; actual packet forwarding still needs to be tested.</p><h3><strong>Configuring IPv6 addressing</strong></h3><p>With the topology deployed and SRv6 enabled, the next step was to configure IPv6 addresses on all six links connecting the GPU hosts, Leaf switches, and Spine switches.</p><p>Assigned IPv6 addresses to both ends of each link:</p><pre># GPU1 - Leaf1<br>gpu1:eth1    2001:db8:10:1::2/64<br>leaf1:eth1   2001:db8:10:1::1/64<br><br># GPU2 - Leaf2<br>gpu2:eth1    2001:db8:10:2::2/64<br>leaf2:eth1   2001:db8:10:2::1/64<br><br># Leaf1 - Spine1<br>leaf1:eth2   2001:db8:11:1::1/64<br>spine1:eth1  2001:db8:11:1::2/64<br><br># Leaf1 - Spine2<br>leaf1:eth3   2001:db8:12:1::1/64<br>spine2:eth1  2001:db8:12:1::2/64<br><br># Leaf2 - Spine1<br>leaf2:eth2   2001:db8:21:1::1/64<br>spine1:eth2  2001:db8:21:1::2/64<br><br># Leaf2 - Spine2<br>leaf2:eth3   2001:db8:22:1::1/64<br>spine2:eth2  2001:db8:22:1::2/64</pre><p>This establishes IPv6 addressing on the point-to-point links. The next step is to verify connectivity between directly connected nodes before configuring routing and NEXT-CSID forwarding.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ for n in gpu1 gpu2 leaf1 leaf2 spine1 spine2; do<br>  echo &quot;===== $n =====&quot;<br>  docker exec clab-srv6-ai-$n ip -6 -br addr<br>done<br>===== gpu1 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if72        UP             3fff:172:20:20::7/64 fe80::64b2:2cff:fe2d:405b/64<br>eth1@if66        UP             2001:db8:10:1::2/64 fe80::a8c1:abff:fe58:97/64<br>===== gpu2 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if56        UP             3fff:172:20:20::2/64 fe80::9c12:4dff:fec4:212/64<br>eth1@if61        UP             2001:db8:10:2::2/64 fe80::a8c1:abff:fe69:1665/64<br>===== leaf1 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if63        UP             3fff:172:20:20::3/64 fe80::6059:88ff:fef0:67c3/64<br>eth2@if58        UP             2001:db8:11:1::1/64 fe80::a8c1:abff:fe5f:8a20/64<br>eth1@if65        UP             2001:db8:10:1::1/64 fe80::a8c1:abff:fedc:1dca/64<br>eth3@if67        UP             2001:db8:12:1::1/64 fe80::a8c1:abff:febf:4e3/64<br>===== leaf2 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if64        UP             3fff:172:20:20::4/64 fe80::b479:5bff:fe48:91ef/64<br>eth2@if60        UP             2001:db8:21:1::1/64 fe80::a8c1:abff:fed0:8c66/64<br>eth1@if62        UP             2001:db8:10:2::1/64 fe80::a8c1:abff:fe07:d214/64<br>eth3@if69        UP             2001:db8:22:1::1/64 fe80::a8c1:abff:feb4:67bb/64<br>===== spine1 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if55        UP             3fff:172:20:20::5/64 fe80::d87c:71ff:fe85:1622/64<br>eth1@if57        UP             2001:db8:11:1::2/64 fe80::a8c1:abff:fe08:4ac6/64<br>eth2@if59        UP             2001:db8:21:1::2/64 fe80::a8c1:abff:fe57:e79c/64<br>===== spine2 =====<br>lo               UNKNOWN        ::1/128<br>eth0@if71        UP             3fff:172:20:20::6/64 fe80::1472:42ff:fe8d:e287/64<br>eth1@if68        UP             2001:db8:12:1::2/64 fe80::a8c1:abff:febf:c8f9/64<br>eth2@if70        UP             2001:db8:22:1::2/64 fe80::a8c1:abff:fe3f:649a/64<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><h3>Verifying IPv6 connectivity</h3><p>After configuring IPv6 addressing, I ran ICMPv6 ping tests to verify connectivity across all six links.</p><p>The tests covered GPU1 &lt;-&gt; Leaf1, GPU2 &lt;-&gt; Leaf2, Leaf1 &lt;-&gt; Spine1, Leaf1 &lt;-&gt; Spine2, Leaf2 &lt;-&gt; Spine1, and Leaf2 &lt;-&gt; Spine2.</p><p>All six connectivity tests passed, with zero packet loss.</p><p>This confirms that IPv6 connectivity is working across all directly connected nodes. Next, I’ll configure routing between GPU1 and GPU2 through both Spine paths.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ #!/bin/bash<br><br>tests=(<br>  &quot;gpu1 2001:db8:10:1::1 GPU1-Leaf1&quot;<br>  &quot;gpu2 2001:db8:10:2::1 GPU2-Leaf2&quot;<br>  &quot;leaf1 2001:db8:11:1::2 Leaf1-Spine1&quot;<br>  &quot;leaf1 2001:db8:12:1::2 Leaf1-Spine2&quot;<br>  &quot;leaf2 2001:db8:21:1::2 Leaf2-Spine1&quot;<br>  &quot;leaf2 2001:db8:22:1::2 Leaf2-Spine2&quot;<br>)<br><br>passed=0<br>failed=0<br><br>echo &quot;========== IPv6 Connectivity Tests ==========&quot;<br><br>for test in &quot;${tests[@]}&quot;; do<br>    read -r node address link &lt;&lt;&lt; &quot;$test&quot;<br><br>    echo<br>    echo &quot;Testing ICMPv6 ping: $link&quot;<br>    echo &quot;Command: docker exec clab-srv6-ai-$node ping -6 -c 2 $address&quot;<br><br>    if docker exec &quot;clab-srv6-ai-$node&quot; ping -6 -c 2 -W 2 &quot;$address&quot;; then<br>        echo &quot;RESULT: [PASS] ICMPv6 connectivity between $link&quot;<br>        ((passed++))<br>    else<br>        echo &quot;RESULT: [FAIL] ICMPv6 connectivity between $link&quot;<br>        ((failed++))<br>    fi<br>done<br><br>echo<br>echo &quot;============== Test Summary ==============&quot;<br>echo &quot;Total links tested : $((passed + failed))&quot;<br>echo &quot;Passed             : $passed&quot;<br>echo &quot;Failed             : $failed&quot;<br>echo &quot;===========================================&quot;<br>========== IPv6 Connectivity Tests ==========<br><br>Testing ICMPv6 ping: GPU1-Leaf1<br>Command: docker exec clab-srv6-ai-gpu1 ping -6 -c 2 2001:db8:10:1::1<br>PING 2001:db8:10:1::1(2001:db8:10:1::1) 56 data bytes<br>64 bytes from 2001:db8:10:1::1: icmp_seq=1 ttl=64 time=0.051 ms<br>64 bytes from 2001:db8:10:1::1: icmp_seq=2 ttl=64 time=0.054 ms<br><br>--- 2001:db8:10:1::1 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1045ms<br>rtt min/avg/max/mdev = 0.051/0.052/0.054/0.001 ms<br>RESULT: [PASS] ICMPv6 connectivity between GPU1-Leaf1<br><br>Testing ICMPv6 ping: GPU2-Leaf2<br>Command: docker exec clab-srv6-ai-gpu2 ping -6 -c 2 2001:db8:10:2::1<br>PING 2001:db8:10:2::1(2001:db8:10:2::1) 56 data bytes<br>64 bytes from 2001:db8:10:2::1: icmp_seq=1 ttl=64 time=0.046 ms<br>64 bytes from 2001:db8:10:2::1: icmp_seq=2 ttl=64 time=0.067 ms<br><br>--- 2001:db8:10:2::1 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1022ms<br>rtt min/avg/max/mdev = 0.046/0.056/0.067/0.010 ms<br>RESULT: [PASS] ICMPv6 connectivity between GPU2-Leaf2<br><br>Testing ICMPv6 ping: Leaf1-Spine1<br>Command: docker exec clab-srv6-ai-leaf1 ping -6 -c 2 2001:db8:11:1::2<br>PING 2001:db8:11:1::2(2001:db8:11:1::2) 56 data bytes<br>64 bytes from 2001:db8:11:1::2: icmp_seq=1 ttl=64 time=0.064 ms<br>64 bytes from 2001:db8:11:1::2: icmp_seq=2 ttl=64 time=0.055 ms<br><br>--- 2001:db8:11:1::2 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1019ms<br>rtt min/avg/max/mdev = 0.055/0.059/0.064/0.004 ms<br>RESULT: [PASS] ICMPv6 connectivity between Leaf1-Spine1<br><br>Testing ICMPv6 ping: Leaf1-Spine2<br>Command: docker exec clab-srv6-ai-leaf1 ping -6 -c 2 2001:db8:12:1::2<br>PING 2001:db8:12:1::2(2001:db8:12:1::2) 56 data bytes<br>64 bytes from 2001:db8:12:1::2: icmp_seq=1 ttl=64 time=0.064 ms<br>64 bytes from 2001:db8:12:1::2: icmp_seq=2 ttl=64 time=0.059 ms<br><br>--- 2001:db8:12:1::2 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1014ms<br>rtt min/avg/max/mdev = 0.059/0.061/0.064/0.002 ms<br>RESULT: [PASS] ICMPv6 connectivity between Leaf1-Spine2<br><br>Testing ICMPv6 ping: Leaf2-Spine1<br>Command: docker exec clab-srv6-ai-leaf2 ping -6 -c 2 2001:db8:21:1::2<br>PING 2001:db8:21:1::2(2001:db8:21:1::2) 56 data bytes<br>64 bytes from 2001:db8:21:1::2: icmp_seq=1 ttl=64 time=0.101 ms<br>64 bytes from 2001:db8:21:1::2: icmp_seq=2 ttl=64 time=0.066 ms<br><br>--- 2001:db8:21:1::2 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1019ms<br>rtt min/avg/max/mdev = 0.066/0.083/0.101/0.017 ms<br>RESULT: [PASS] ICMPv6 connectivity between Leaf2-Spine1<br><br>Testing ICMPv6 ping: Leaf2-Spine2<br>Command: docker exec clab-srv6-ai-leaf2 ping -6 -c 2 2001:db8:22:1::2<br>PING 2001:db8:22:1::2(2001:db8:22:1::2) 56 data bytes<br>64 bytes from 2001:db8:22:1::2: icmp_seq=1 ttl=64 time=0.069 ms<br>64 bytes from 2001:db8:22:1::2: icmp_seq=2 ttl=64 time=0.077 ms<br><br>--- 2001:db8:22:1::2 ping statistics ---<br>2 packets transmitted, 2 received, 0% packet loss, time 1010ms<br>rtt min/avg/max/mdev = 0.069/0.073/0.077/0.004 ms<br>RESULT: [PASS] ICMPv6 connectivity between Leaf2-Spine2<br><br>============== Test Summary ==============<br>Total links tested : 6<br>Passed             : 6<br>Failed             : 0<br>===========================================<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><p><strong>Configuring Static IPv6 Routes</strong></p><p>Since we’re not running a dynamic routing protocol , I configured static IPv6 routes to establish end-to-end connectivity between GPU1 and GPU2.</p><p>I started with <strong>Path A via Spine1</strong>:</p><p>GPU1 → Leaf1 → Spine1 → Leaf2 → GPU2</p><p>Configured static routes on the GPU hosts, Leaf switches, and Spine1, pointing to the appropriate next-hop IPv6 addresses. Also configured reverse routes to ensure return traffic follows the same path.</p><p>This establishes basic IPv6 connectivity through Spine1. I’ll test end-to-end connectivity before configuring the second path through Spine2.</p><p><strong>Note:</strong> These are regular IPv6 static routes. NEXT-CSID-based forwarding and source-side traffic spraying will be explored separately.</p><pre># GPU1 -&gt; GPU2 via Leaf1<br>docker exec -u 0 clab-srv6-ai-gpu1 \<br>  ip -6 route replace 2001:db8:10:2::/64 \<br>  via 2001:db8:10:1::1 dev eth1<br><br># Leaf1 -&gt; GPU2 via Spine1<br>docker exec -u 0 clab-srv6-ai-leaf1 \<br>  ip -6 route replace 2001:db8:10:2::/64 \<br>  via 2001:db8:11:1::2 dev eth2<br><br># Spine1 -&gt; GPU2 via Leaf2<br>docker exec -u 0 clab-srv6-ai-spine1 \<br>  ip -6 route replace 2001:db8:10:2::/64 \<br>  via 2001:db8:21:1::1 dev eth2<br><br># GPU2 -&gt; GPU1 via Leaf2<br>docker exec -u 0 clab-srv6-ai-gpu2 \<br>  ip -6 route replace 2001:db8:10:1::/64 \<br>  via 2001:db8:10:2::1 dev eth1<br><br># Leaf2 -&gt; GPU1 via Spine1<br>docker exec -u 0 clab-srv6-ai-leaf2 \<br>  ip -6 route replace 2001:db8:10:1::/64 \<br>  via 2001:db8:21:1::2 dev eth2<br><br># Spine1 -&gt; GPU1 via Leaf1<br>docker exec -u 0 clab-srv6-ai-spine1 \<br>  ip -6 route replace 2001:db8:10:1::/64 \<br>  via 2001:db8:11:1::1 dev eth1</pre><p><strong>Testing end-to-end connectivity</strong></p><p>Tested end-to-end IPv6 connectivity between GPU1 and GPU2 using ping.</p><pre>docker exec clab-srv6-ai-gpu1 ping -6 -c 4 2001:db8:10:2::2</pre><p>All four packets were successfully delivered with zero packet loss.</p><p>Next, I used traceroute to verify the forwarding path.</p><pre>docker exec clab-srv6-ai-gpu1 traceroute -6 -n 2001:db8:10:2::2</pre><p>The output confirmed the following path:</p><p>GPU1 → Leaf1 → Spine1 → Leaf2 → GPU2</p><p>This verifies end-to-end IPv6 connectivity and confirms that traffic is being forwarded through Spine1 using the configured static routes.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-gpu1 ping -6 -c 4 2001:db8:10:2::2<br>PING 2001:db8:10:2::2(2001:db8:10:2::2) 56 data bytes<br>64 bytes from 2001:db8:10:2::2: icmp_seq=1 ttl=61 time=0.093 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=2 ttl=61 time=0.076 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=3 ttl=61 time=0.113 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=4 ttl=61 time=0.079 ms<br><br>--- 2001:db8:10:2::2 ping statistics ---<br>4 packets transmitted, 4 received, 0% packet loss, time 3110ms<br>rtt min/avg/max/mdev = 0.076/0.090/0.113/0.014 ms<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-gpu1 sh -c &#39;command -v traceroute || command -v tracepath || command -v traceroute6&#39;<br>/usr/bin/traceroute<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-gpu1 traceroute -6 -n 2001:db8:10:2::2<br>traceroute to 2001:db8:10:2::2 (2001:db8:10:2::2), 30 hops max, 72 byte packets<br> 1  2001:db8:10:1::1  0.011 ms  0.007 ms  0.008 ms<br> 2  2001:db8:11:1::2  0.005 ms  0.008 ms  0.007 ms<br> 3  2001:db8:21:1::1  0.006 ms  0.006 ms  0.009 ms<br> 4  2001:db8:10:2::2  0.008 ms  0.007 ms  0.007 ms<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><h3><strong>Testing the second forwarding path</strong></h3><p>Configured static IPv6 routes to steer traffic through Spine2 (instead of Spine1 we did earlier) and tested end-to-end connectivity between GPU1 and GPU2.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ # Leaf1 -&gt; GPU2 via Spine2<br>docker exec -u 0 clab-srv6-ai-leaf1 \<br>  ip -6 route replace 2001:db8:10:2::/64 \<br>  via 2001:db8:12:1::2 dev eth3<br><br># Spine2 -&gt; GPU2 via Leaf2<br>docker exec -u 0 clab-srv6-ai-spine2 \<br>  ip -6 route replace 2001:db8:10:2::/64 \<br>  via 2001:db8:22:1::1 dev eth2<br><br># Leaf2 -&gt; GPU1 via Spine2<br>docker exec -u 0 clab-srv6-ai-leaf2 \<br>  ip -6 route replace 2001:db8:10:1::/64 \<br>  via 2001:db8:22:1::2 dev eth3<br><br># Spine2 -&gt; GPU1 via Leaf1<br>docker exec -u 0 clab-srv6-ai-spine2 \<br>  ip -6 route replace 2001:db8:10:1::/64 \<br>  via 2001:db8:12:1::1 dev eth1<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$^</pre><pre>docker exec clab-srv6-ai-gpu1 ping -6 -c 4 2001:db8:10:2::2</pre><p>Verified the forwarding path using traceroute.</p><pre>docker exec clab-srv6-ai-gpu1 traceroute -6 -n 2001:db8:10:2::2</pre><p>The output confirmed the path:</p><p>GPU1 → Leaf1 → Spine2 → Leaf2 → GPU2</p><p>Both tests succeeded, confirming IPv6 connectivity through the second spine path.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-gpu1 ping -6 -c 4 2001:db8:10:2::2<br>PING 2001:db8:10:2::2(2001:db8:10:2::2) 56 data bytes<br>64 bytes from 2001:db8:10:2::2: icmp_seq=1 ttl=61 time=0.093 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=2 ttl=61 time=0.081 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=3 ttl=61 time=0.084 ms<br>64 bytes from 2001:db8:10:2::2: icmp_seq=4 ttl=61 time=0.116 ms<br><br>--- 2001:db8:10:2::2 ping statistics ---<br>4 packets transmitted, 4 received, 0% packet loss, time 3082ms<br>rtt min/avg/max/mdev = 0.081/0.093/0.116/0.013 ms<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-gpu1 traceroute -6 -n 2001:db8:10:2::2<br>traceroute to 2001:db8:10:2::2 (2001:db8:10:2::2), 30 hops max, 72 byte packets<br> 1  2001:db8:10:1::1  0.017 ms  0.016 ms  0.007 ms<br> 2  2001:db8:12:1::2  0.007 ms  0.008 ms  0.017 ms<br> 3  2001:db8:22:1::1  0.053 ms  0.006 ms  0.007 ms<br> 4  2001:db8:10:2::2  0.008 ms  0.008 ms  0.137 ms<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><h3>Checking NEXT-CSID Support</h3><p>Before configuring SRv6 NEXT-CSID, quick check to confirm whether the Linux kernel and iproute2 inside the router containers support the required functionality.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ for n in leaf1 leaf2 spine1 spine2; do<br>    echo &quot;========== $n ==========&quot;<br>    docker exec clab-srv6-ai-$n sh -c &#39;<br>        echo &quot;--- Kernel ---&quot;<br>        uname -r<br><br>        echo &quot;--- iproute2 ---&quot;<br>        ip -Version<br><br>        echo &quot;--- NEXT-CSID support ---&quot;<br>        ip -6 route help 2&gt;&amp;1 | grep -i -E &quot;next-csid|seg6local|flavors&quot;<br>    &#39;<br>done</pre><p>The output showed the following on all four routers:</p><ul><li>Linux kernel: 7.0.0-1017-azure</li><li>iproute2: 6.3.0</li><li>seg6local available in the route syntax</li><li>next-csid listed as a supported flavor</li></ul><p>Example output:</p><pre>========== leaf1 ==========<br>--- Kernel ---<br>7.0.0-1017-azure<br>--- iproute2 ---<br>ip utility, iproute2-6.3.0<br>--- NEXT-CSID support ---<br>ENCAPTYPE := [ mpls | ip | ip6 | seg6 | seg6local | rpl | ioam6 | xfrm ]<br>ENCAPHDR := [ MPLSLABEL | SEG6HDR | SEG6LOCAL | IOAM6HDR | XFRMINFO ]<br>SEG6LOCAL := action ACTION [ OPTIONS ] [ count ]<br>OPTION := { flavors FLAVORS | srh SEG6HDR | nh4 ADDR | nh6 ADDR | iif DEV | oif DEV |<br>FLAVORS := { FLAVOR[,FLAVOR] }<br>FLAVOR := { psp | usp | usd | next-csid }</pre><p>The same output was observed on Leaf2, Spine1 and Spine2, whch confirms that the installed iproute2 utility recognizes the NEXT-CSID configuration syntax. However, this check alone does not prove that the kernel accepts or correctly processes NEXT-CSID packets.</p><p>The next step is to install a test NEXT-CSID local SID on Leaf1 and verify kernel acceptance.</p><h3>Installing and Verifying NEXT-CSID Local SIDs</h3><p>I started by installing a test NEXT-CSID local SID on Leaf1.</p><pre>docker exec -u 0 clab-srv6-ai-leaf1 \<br>  ip -6 route replace 5f00:0:0100::/48 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev lo</pre><p>Interpreting above command:</p><p>(Note: <strong>5f00::/16</strong> was officially reserved by IANA (via RFC 9602) specifically for SRv6 SIDs)</p><p><em>ip -6 route replace 5f00:0:0100::/48</em>: Creates a routing rule matching incoming packets whose Destination Address starts with 5f00:0000:0100.<br>5f00:0000 (32 bits) is the official IANA SRv6 domain prefix shared across this lab ; 0100 (16 bits) is leaf1’s unique Node ID.</p><p>Further, <br><em>encap seg6local action End</em>: Tells leaf1’s Linux kernel to execute the SRv6 Endpoint (End) instruction rather than standard routing.</p><p><em>flavors next-csid lblen 32 nflen 16</em>: Enables NEXT-C-SID (compressed micro-SID) shifting.<br><em>lblen 32 </em>keeps the first 32 bits (5f00:0000) locked in place.<br><em>nflen 16 </em>defines each Node ID as 16 bits. leaf1 deletes its own 0100 from the active slot and slides the next stop (e.g., 0600 for spine2) left into its place</p><p>Verification of the installed route:</p><pre>docker exec clab-srv6-ai-leaf1 \<br>  ip -6 route show 5f00:0:0100::/48</pre><p>The kernel accepted the configuration and displayed the End behavior with the next-csid flavor.</p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$ docker exec clab-srv6-ai-leaf1 \<br>  ip -6 route show 5f00:0:0100::/48<br>5f00:0:100::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev lo metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6-ai-backend$</pre><p>Repeated the same configuration on Spine2 and Leaf2, using their respective SIDs:</p><ul><li>Leaf1: 5f00:0:0100::/48</li><li>Spine2: 5f00:0:0600::/48</li><li>Leaf2: 5f00:0:0200::/48</li></ul><p>This confirms that the kernel accepted the NEXT-CSID local SID configuration on all three routers. Packet processing has not yet been tested.</p><h3>Configuring SID Reachability</h3><p>After installing the NEXT-CSID local SIDs, I configured IPv6 static routes to provide reachability between the SIDs along Path B.</p><p>(need reachability between the SIDs because NEXT-CSID tells a router what the next segment is, but it does not automatically tell the router how to physically reach the next router.)</p><p>First, I configured Leaf1 to reach Spine2’s SID through the Spine2-facing interface (eth3).</p><pre>docker exec -u 0 clab-srv6-ai-leaf1 \<br>  ip -6 route replace 5f00:0:0600::/48 \<br>  via 2001:db8:12:1::2 dev eth3</pre><p>Route lookup verification:</p><pre>docker exec clab-srv6-ai-leaf1 \<br>  ip -6 route get 5f00:0:0600::1</pre><p>The output confirmed that traffic destined for Spine2’s SID would be forwarded through 2001:db8:12:1::2 using eth3.</p><p>Next, configured Spine2 to reach Leaf2’s SID through eth2.</p><pre>docker exec -u 0 clab-srv6-ai-spine2 \<br>  ip -6 route replace 5f00:0:0200::/48 \<br>  via 2001:db8:22:1::1 dev eth2</pre><p>Route lookup verification:</p><pre>docker exec clab-srv6-ai-spine2 \<br>  ip -6 route get 5f00:0:0200::1</pre><p>The output confirmed that traffic destined for Leaf2’s SID would be forwarded through 2001:db8:22:1::1 using eth2.</p><p>This establishes the static forwarding reachability required for the Path B SID sequence:</p><p><strong>Leaf1 → Spine2 → Leaf2</strong></p><p>At this stage, the SID routes are installed and the next-hop lookups are verified.</p><p>As an example, <br>1. Initial packet at Leaf1<br>GPU1 sends a packet with this IPv6 destination address:<br>5f00:0000:0100:0600:0200:0000:0000:0000</p><p>The compressed SID sequence is:<br>- 0100 = Leaf1<br>- 0600 = Spine2<br>- 0200 = Leaf2</p><p>2. Leaf1 processes its NEXT-CSID behavior<br>Leaf1 recognizes its local SID (0100) and advances the active micro-segment.<br>Conceptually, the destination address becomes:<br>5f00:0000:0600:0200:0000:0000:0000:0000<br>Now the active SID is 0600, belonging to Spine2.</p><p>3. How does Leaf1 forward the packet?<br>This is where the static route comes in.<br>Leaf1 performs an IPv6 routing lookup for the updated destination address.It finds, something as<br>5f00:0:0600::/48<br> via 2001:db8:12:1::2<br> dev eth3<br>Therefore, Leaf1 forwards the packet to Spine2 over eth3<br>Without this route, Leaf1 might not have a usable forwarding entry for the updated destination.</p><p>4. Spine2 repeats the process</p><h3>Understanding the NEXT-CSID Packet Format</h3><p>Before testing NEXT-CSID forwarding, how the source encodes the forwarding path in the IPv6 destination address ?</p><p>For Path B (GPU1 → Leaf1 → Spine2 → Leaf2 → GPU2), the source uses the following destination address:</p><pre>5f00:0000:0100:0600:0200:0000:0000:0000</pre><p>The address contains a 32-bit fabric locator followed by three 16-bit micro-segments:</p><ul><li>0100: Leaf1 ; 0600: Spine2 ; 0200: Leaf2</li></ul><p>With NEXT-CSID, each router processes its local micro-segment and advances the IPv6 destination address to expose the next one.</p><p>The expected destination-address progression is:<br>GPU1 sends 5f00:0000:0100:0600:0200::<br>After Leaf1 5f00:0000:0600:0200::<br>After Spine2 5f00:0000:0200::</p><p>This allows multiple micro-segments to be encoded in a single IPv6 destination address without requiring a separate SRH to carry the segment list.</p><p>The important point is that the IPv6 address is divided into a <strong>32-bit locator followed by 16-bit micro-segment slots</strong>. Our example address is:</p><pre>5f00:0000:0100:0600:0200:0000:0000:0000</pre><p>An IPv6 address contains 128 bits (8 groups of 16 bits). With lblen = 32 (32-bit locator) and nflen = 16 (16-bit uSIDs), the address maps directly to our router configuration:</p><pre>128-bit IPv6 destination address: 5f00:0000:0100:0600:0200:0000:0000:0000<br>• Locator (32 bits): 5f00:0000<br>• uSID 1 (16 bits): 0100<br>• uSID 2 (16 bits): 0600<br>• uSID 3 (16 bits): 0200<br>• Unused (48 bits): 0000:0000:0000 (three unused 16-bit slots)<br>Summary: Locator: 32 bits | Three uSIDs: 48 bits | Unused: 48 bits</pre><p>My intent is to see the final packet processing and delivery to GPU2 in subsequent steps.</p><h3>Configuring NEXT-CSID on the Routers</h3><p>I started by enabling IPv6 forwarding and SRv6 on the routers. On Leaf1, we checked the kernel settings:</p><pre>sysctl net.ipv6.conf.all.forwarding<br>sysctl net.ipv6.conf.all.seg6_enabled</pre><p>The output confirmed that both were enabled:</p><pre>net.ipv6.conf.all.forwarding = 1<br>net.ipv6.conf.all.seg6_enabled = 1</pre><p>Then configured the local SID on Leaf1 with NEXT-CSID:</p><pre>ip -6 route add 5f00:0:100::/48 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev lo</pre><p>Here, 5f00:0:100::/48 is Leaf1&#39;s local SID prefix. The End action instructs Leaf1 to intercept any incoming packet whose IPv6 Destination Address matches Leaf1&#39;s local SID prefix, update that Destination Address to the next waypoint in the segment path, and forward the packet onward. next-csid enables NEXT-CSID compressed processing by left-shifting the next 16-bit C-SID into the active position. We used a 32-bit Locator-Block length (lblen 32) and a 16-bit Locator-Node and Function length (nflen 16). Finally, this local SID route was bound to the loopback interface (dev lo).</p><p><strong>Testing the initial configuration</strong></p><p>To test the configuration, we generated a UDP packet from GPU1 with the destination address carrying the uSID sequence 5f00:0:100:600:200::.</p><p>The packet was sent using Scapy:</p><pre>sudo docker exec -i clab-srv6-ai-gpu1 python3 - &lt;&lt;&#39;PY&#39;<br>from scapy.all import Ether, IPv6, UDP, Raw, sendp<br>packet = Ether(dst=&quot;aa:c1:ab:36:aa:c8&quot;) / IPv6(<br>    src=&quot;2001:db8:10:1::2&quot;,<br>    dst=&quot;5f00:0:100:600:200::&quot;,<br>    hlim=64<br>) / UDP(sport=50000, dport=9000) / Raw(b&quot;CSID-TEST-001&quot;)<br>sendp(packet, iface=&quot;eth1&quot;, count=1, verbose=True)<br>PY</pre><p>Scapy confirmed that the packet was transmitted:</p><pre>Sent 1 packets.</pre><p>In a parallel terminal, i captured traffic on Leaf1’s incoming interface, eth1:</p><pre>docker exec -it clab-srv6-ai-leaf1 \<br>  tcpdump -ni eth1 -vvv &#39;ip6 and udp port 9000&#39;</pre><p>The capture showed the UDP packet from GPU1 destined for Leaf1’s local SID:</p><pre>09:21:11.447021 ... 2001:db8:10:1::2.50000 &gt; 5f00:0:100:600:200::.9000 ...</pre><p>This confirmed that the packet reached Leaf1. Upon checking, Leaf1’s outgoing interface, eth3, which connects to Spine2:</p><pre>docker exec -it clab-srv6-ai-leaf1 \<br>  tcpdump -ni eth3 -vvv &#39;ip6 and udp port 9000&#39;</pre><p>The initial capture did not show the test UDP packet leaving Leaf1. Further, capturing on all Leaf1 interfaces:</p><pre>docker exec -it clab-srv6-ai-leaf1 \<br>  tcpdump -ni any -vvv -e &#39;ip6&#39;</pre><p>This capture showed an ICMPv6 error:</p><pre>ICMP6, destination unreachable, unreachable route 5f00:0:100:600:200::</pre><p>The packet had reached Leaf1, but the router reported that it could not find a route for the destination. The initial dev lo configuration therefore did not produce the expected forwarding behavior in our lab. So far, i don’t know the exact root cause of this yet.</p><p><strong>Changing the local SID route to use dum0</strong></p><p>To investigate and address the forwarding behavior, I changed the local SID route to use a dummy interface named dum0 instead of lo and introduced a dedicated IPv6 routing table, table 90, and a policy rule to direct traffic matching the SID address space into that table.</p><p>On Leaf1, we ran:</p><pre>ip link add dum0 type dummy 2&gt;/dev/null || true<br>ip link set dum0 up</pre><pre>ip -6 route replace 5f00:0:100::/48 table 90 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev dum0</pre><pre>ip -6 route replace 5f00:0:600::/48 table 90 \<br>  via 2001:db8:12:1::2 dev eth3</pre><pre>ip -6 rule add to 5f00::/32 lookup 90 priority 999</pre><p>The dummy interface dum0 was used as the device for the local SID route. Table 90 contained the local SID route and the route towards the next router. The policy rule directed packets destined for 5f00::/32 to this table.</p><p>Further, upon repeating the packet capture on Leaf1’s outgoing interface, eth3:</p><pre>tcpdump -ni eth3 -vvv &#39;ip6&#39;</pre><p>This time, the capture showed the packet leaving Leaf1:</p><pre>08:51:48.850712 IP6 (hlim 63 ...) 2001:db8:10:1::2.50000 &gt; 5f00:0:600:200::.9000 ...</pre><p>Compare the destination address before and after Leaf1:</p><ul><li>Packet sent by GPU1: 5f00:0:100:600:200::</li><li>Packet observed leaving Leaf1: 5f00:0:600:200::</li></ul><p>The 0100 micro-segment had been consumed, and the destination had advanced to the next uSID. The hop limit had also decreased to 63.</p><p>This was the key evidence that the updated Leaf1 configuration was working: unlike the initial test, the packet was now visible leaving Leaf1 through eth3 towards Spine2. The capture also showed an ICMPv6 unreachable message associated with the next hop, indicating that forwarding beyond Leaf1 still needed to be configured.</p><p><strong>Configuring NEXT-CSID on the remaining routers</strong></p><p>With Leaf1 forwarding the packet to the next hop, configured the corresponding local SID and forwarding entries on Spine2.</p><p>On Spine2:</p><pre>ip link add dum0 type dummy 2&gt;/dev/null || true<br>ip link set dum0 up</pre><pre>ip -6 route replace 5f00:0:600::/48 table 90 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev dum0</pre><pre>ip -6 route replace 5f00:0:200::/48 table 90 \<br>  via 2001:db8:22:1::1 dev eth2</pre><pre>ip -6 rule add to 5f00::/32 lookup 90 priority 999</pre><p>And on Leaf2:</p><pre>ip link add dum0 type dummy 2&gt;/dev/null || true<br>ip link set dum0 up</pre><pre>ip -6 route replace 5f00:0:200::/48 table 90 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev dum0</pre><pre>ip -6 route replace 2001:db8:10:2::/64 table 90 \<br>  via 2001:db8:10:2::2 dev eth1</pre><pre>ip -6 rule add to 5f00::/32 lookup 90 priority 999</pre><p>The selected path for this lab is GPU1 → Leaf1 → Spine2 → Leaf2 → GPU2. Each router on this path has a local SID route for its assigned uSID block. The dedicated routing table provides the corresponding next-hop forwarding entries, while the policy rule directs matching SID traffic to table 90.</p><p>The important observation from this stage was that changing the local SID route from dev lo to dev dum0, together with the dedicated routing table and policy rule, allowed Leaf1 to process the first micro-segment and forward the packet towards Spine2.</p><h3>Completing the End-to-End Path</h3><p>After confirming that Leaf1 could process its uSID and forward the packet towards Spine2, the remaining part of the path was configured. On Leaf2, configured its local SID and the route towards GPU2 using table 90:</p><pre>ip link add dum0 type dummy 2&gt;/dev/null || true<br>ip link set dum0 up</pre><pre>ip -6 route replace 5f00:0:200::/48 table 90 \<br>  encap seg6local action End \<br>  flavors next-csid lblen 32 nflen 16 \<br>  dev dum0</pre><pre>ip -6 route replace 2001:db8:10:2::/64 table 90 \<br>  via 2001:db8:10:2::2 dev eth1</pre><pre>ip -6 rule add to 5f00::/32 lookup 90 priority 999</pre><p>Further, checked the policy rule and routing table on Leaf2:</p><pre>ip -6 rule show<br>ip -6 route show table 90</pre><p>The output confirmed that traffic destined for 5f00::/32 would use table 90 and that Leaf2 had the NEXT-CSID local SID route installed:</p><pre>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main</pre><pre>2001:db8:10:2::/64 via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>5f00:0:200::/48 encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium</pre><p>We then checked GPU2’s interface:</p><pre>ip -6 addr show dev eth1</pre><p>The output showed:</p><pre>eth1@if31 UP<br>    inet6 2001:db8:10:2::2/64<br>    inet6 fe80::a8c1:abff:fe67:9d73/64</pre><p><strong>Initial end-to-end test</strong></p><p>We sent a UDP packet from GPU1 using the uSID sequence:</p><pre>5f00:0:100:600:200::</pre><p>The packet reached the earlier routers, but GPU2’s capture showed no packet. Assigning 5f00::/128 to GPU2 and adding a corresponding route on Leaf2 did not resolve the issue.</p><p>The problem was that the uSID sequence ended at 5f00:0:200:: when it reached Leaf2. There was no further uSID identifying the final destination on GPU2.</p><p><strong>Adding the final uSID</strong></p><p>We therefore introduced another uSID, 0300, for GPU2.</p><p>On GPU2, we assigned the final SID to its loopback interface:</p><pre>ip -6 addr replace 5f00:0:300::/128 dev lo</pre><p>On Leaf2, we added a route for this final SID towards GPU2:</p><pre>ip -6 route replace 5f00:0:300::/48 table 90 \<br>  via 2001:db8:10:2::2 dev eth1</pre><p>The complete uSID sequence was now:</p><pre>5f00:0:100:600:200:300::</pre><p>This represents the selected path:</p><p>GPU1 → Leaf1 → Spine2 → Leaf2 → GPU2</p><p><strong>Successful end-to-end packet test</strong></p><p>We repeated the test from GPU1, this time using the complete uSID sequence.</p><p>The packet was constructed and transmitted using Scapy:</p><pre>sudo docker exec -i clab-srv6-ai-gpu1 python3 - &lt;&lt;&#39;PY&#39;<br>from scapy.all import Ether, IPv6, UDP, Raw, sendp<br>p = IPv6(src=&quot;2001:db8:10:1::2&quot;,<br>         dst=&quot;5f00:0:300::&quot;,<br>         hlim=64) / UDP(sport=50000, dport=9000) / Raw(b&quot;CSID-END-TO-END-TEST&quot;)<br>p = IPv6(bytes(p))<br>p.dst = &quot;5f00:0:100:600:200:300::&quot;<br>sendp(Ether(dst=&quot;aa:c1:ab:36:aa:c8&quot;) / p,<br>      iface=&quot;eth1&quot;, count=1, verbose=True)<br>PY</pre><p>We started a packet capture on GPU2 to check whether the packet reached the destination:</p><pre>sudo docker exec -it clab-srv6-ai-gpu2 \<br>  tcpdump -ni eth1 -vv &#39;ip6 and udp dst port 9000&#39;</pre><p>The capture showed the UDP packet arriving at GPU2:</p><pre>11:02:07.482258 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:300::.9000: UDP, length 21<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel</pre><p>We also captured the packet on Leaf2’s outgoing interface, eth1:</p><pre>11:02:07.482256 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:300::.9000: UDP, length 21<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel</pre><p>The two captures confirmed that the packet reached Leaf2’s GPU-facing interface and was also received by GPU2.</p><p>The final destination address observed at GPU2 was 5f00:0:300::, confirming that the last uSID had been consumed at Leaf2 and the packet had reached its configured destination.</p><p>With the additional 0300 uSID, the packet successfully traversed the complete path from GPU1 to GPU2.</p><p>Path, as seen from tcpdump captures:</p><pre>containerlab_ubuntu_vm@containerLab001:~$<br>containerlab_ubuntu_vm@containerLab001:~$<br>cat &lt;&lt;&#39;EOF&#39; &gt; /tmp/srv6-path-proof.sh<br>#!/usr/bin/env bash<br>set -e<br><br>NODES=(gpu1 leaf1 spine2 leaf2 gpu2)<br>CAPDIR=/tmp/srv6-captures<br><br>mkdir -p &quot;$CAPDIR&quot;<br>rm -f &quot;$CAPDIR&quot;/*.txt<br><br>echo &quot;==================================================&quot;<br>echo &quot; SRv6 NEXT-CSID PATH CONFIGURATION&quot;<br>echo &quot;==================================================&quot;<br><br>for NODE in &quot;${NODES[@]}&quot;; do<br>    echo<br>    echo &quot;========== ${NODE^^} ==========&quot;<br><br>    case &quot;$NODE&quot; in<br>        gpu1|gpu2)<br>            docker exec &quot;clab-srv6-ai-$NODE&quot; ip -6 addr show<br>            ;;<br>        *)<br>            docker exec &quot;clab-srv6-ai-$NODE&quot; sh -c &#39;<br>                echo &quot;--- Table 90 ---&quot;<br>                ip -6 route show table 90<br>                echo &quot;--- IPv6 rules ---&quot;<br>                ip -6 rule show<br>            &#39;<br>            ;;<br>    esac<br>done<br><br>echo<br>echo &quot;==================================================&quot;<br>echo &quot; STARTING PACKET CAPTURES&quot;<br>sudo /tmp/srv6-path-proof.shf.sh========================&quot;)path.<br>==================================================<br> SRv6 NEXT-CSID PATH CONFIGURATION<br>==================================================<br><br>========== GPU1 ==========<br>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 state UNKNOWN qlen 1000<br>    inet6 ::1/128 scope host<br>       valid_lft forever preferred_lft forever<br>2: eth0@if19: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 state UP<br>    inet6 3fff:172:20:20::5/64 scope global nodad<br>       valid_lft forever preferred_lft forever<br>    inet6 fe80::49e:c0ff:fedb:9389/64 scope link<br>       valid_lft forever preferred_lft forever<br>22: eth1@if21: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 9500 state UP<br>    inet6 2001:db8:10:1::2/64 scope global<br>       valid_lft forever preferred_lft forever<br>    inet6 fe80::a8c1:abff:fed1:29e1/64 scope link<br>       valid_lft forever preferred_lft forever<br><br>========== LEAF1 ==========<br>--- Table 90 ---<br>5f00:0:100::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br>5f00:0:600::/48 via 2001:db8:12:1::2 dev eth3 metric 1024 pref medium<br>--- IPv6 rules ---<br>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main<br><br>========== SPINE2 ==========<br>--- Table 90 ---<br>5f00:0:200::/48 via 2001:db8:22:1::1 dev eth2 metric 1024 pref medium<br>5f00:0:600::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br>--- IPv6 rules ---<br>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main<br><br>========== LEAF2 ==========<br>--- Table 90 ---<br>2001:db8:10:2::/64 via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>5f00:: via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>5f00:0:200::/48  encap seg6local action End flavors next-csid lblen 32 nflen 16 dev dum0 metric 1024 pref medium<br>5f00:0:300::/48 via 2001:db8:10:2::2 dev eth1 metric 1024 pref medium<br>--- IPv6 rules ---<br>0:      from all lookup local<br>999:    from all to 5f00::/32 lookup 90<br>32766:  from all lookup main<br><br>========== GPU2 ==========<br>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 state UNKNOWN qlen 1000<br>    inet6 5f00:0:300::/128 scope global<br>       valid_lft forever preferred_lft forever<br>    inet6 5f00::/128 scope global<br>       valid_lft forever preferred_lft forever<br>    inet6 ::1/128 scope host<br>       valid_lft forever preferred_lft forever<br>2: eth0@if28: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 state UP<br>    inet6 3fff:172:20:20::6/64 scope global nodad<br>       valid_lft forever preferred_lft forever<br>    inet6 fe80::587d:6ff:fecd:5363/64 scope link<br>       valid_lft forever preferred_lft forever<br>32: eth1@if31: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 9500 state UP<br>    inet6 2001:db8:10:2::2/64 scope global<br>       valid_lft forever preferred_lft forever<br>    inet6 fe80::a8c1:abff:fe67:9d73/64 scope link<br>       valid_lft forever preferred_lft forever<br><br>==================================================<br> STARTING PACKET CAPTURES<br>==================================================<br><br>==================================================<br> SENDING TEST PACKET FROM GPU1<br>==================================================<br>.<br>Sent 1 packets.<br><br>Waiting for captures to finish...<br><br>==================================================<br> PACKET CAPTURE RESULTS<br>==================================================<br><br>========== GPU1 / eth1 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248237 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:100:600:200:300::.9000: UDP, length 15<br><br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br>========== LEAF1 / eth1 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248243 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:100:600:200:300::.9000: UDP, length 15<br><br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br>========== LEAF1 / eth3 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth3, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248272 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:600:200:300::.9000: UDP, length 15<br><br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br>========== SPINE2 / eth1 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248278 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:600:200:300::.9000: UDP, length 15<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br><br>========== SPINE2 / eth2 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth2, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248289 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:200:300::.9000: UDP, length 15<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br><br>========== LEAF2 / eth3 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth3, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248290 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:200:300::.9000: UDP, length 15<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br><br>========== LEAF2 / eth1 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248300 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:300::.9000: UDP, length 15<br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br><br>========== GPU2 / eth1 ==========<br>tcpdump: verbose output suppressed, use -v[v]... for full protocol decode<br>listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes<br>13:17:10.248301 IP6 2001:db8:10:1::2.50000 &gt; 5f00:0:300::.9000: UDP, length 15<br><br>1 packet captured<br>1 packet received by filter<br>0 packets dropped by kernel<br><br>==================================================<br> EXPECTED DESTINATION PROGRESSION<br>==================================================<br>GPU1   : 5f00:0:100:600:200:300::<br>Leaf1  : 5f00:0:600:200:300::<br>Spine2 : 5f00:0:200:300::<br>Leaf2  : 5f00:0:300::<br>GPU2   : 5f00:0:300::<br><br>Capture files: /tmp/srv6-captures<br>==================================================<br>containerlab_ubuntu_vm@containerLab001:~$</pre><p>This is just the first step. In the next part, I plan to build on this lab by exploring the second SRv6 path, steering traffic across both paths, and testing how the network handles path failures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d33aa01c19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building SRv6 Fabric in Containerlab]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/building-srv6-fabric-in-containerlab-e497925d8681?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/e497925d8681</guid>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 18:59:07 GMT</pubDate>
            <atom:updated>2026-04-06T02:47:43.835Z</atom:updated>
            <content:encoded><![CDATA[<p>The intersection of AI infrastructure and Segment Routing appears to be one of the frequently discussed topics right now. Sometime back, i came across the SRv6 AI Backend <a href="https://datatracker.ietf.org/doc/draft-filsfils-srv6ops-srv6-ai-backend/">draft </a>; I’ve always found that a good way to learn is to build. While i continue to read, I used Containerlab to spin up a a basic SRv6 fabric. This serves as a proof-of-concept that helps me see the protocol in action. This is my starting point, and I’ll be evolving this setup as I continue to explore the details of the draft.</p><p><strong><em>Why SRv6 for the AI Backend?<br></em></strong>In a traditional data center, the network is built for general-purpose traffic. However, in context of an AI Backend — it connects thousands of GPUs that must work together like one giant computer.</p><p>SRv6 helps because it gives :</p><p><em>Isolation</em>: Each AI training job seems to be separated from others using IPv6 headers.</p><p><em>Path control</em>: SRv6 lets us send GPU traffic through specific paths we choose. This avoids congested links.</p><p><em>Scaling</em>: Even with tens of thousands of GPUs, the switches in the middle stay simple. They don’t need to remember lots of rules. The smart decisions stay at the edge (the hosts/DPUs).</p><p><strong><em>Lab Topology &amp; Addressing</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*vcUqB0UdJ8F3rk9bmIsgUA.png" /></figure><pre>Node    Role in Fabric            IP Subnet (Underlay)<br>Host1   GPU Worker (Source)       2001:db8:1::/64<br>Router1 Ingress PE / SR-Gateway   2001:db8:12::/64 (Backbone)<br>Router2 Egress PE / SR-Gateway    2001:db8:12::/64 (Backbone)<br>Host2   Parameter Server (Dest)   2001:db8:2::/64</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ cat topo.yml<br>name: srv6-underlay<br>topology:<br>  nodes:<br>    host1:<br>      kind: linux<br>      image: wbitt/network-multitool<br>    router1:<br>      kind: linux<br>      image: frrouting/frr:latest<br>    router2:<br>      kind: linux<br>      image: frrouting/frr:latest<br>    host2:<br>      kind: linux<br>      image: wbitt/network-multitool<br><br>  links:<br>    - endpoints: [&quot;host1:eth1&quot;, &quot;router1:eth1&quot;]<br>    - endpoints: [&quot;router1:eth2&quot;, &quot;router2:eth1&quot;]<br>    - endpoints: [&quot;router2:eth2&quot;, &quot;host2:eth1&quot;]<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uXWqek-tofJjI47UAyZ7A.png" /></figure><p><strong><em>Setting up the underlay</em></strong></p><p>Before building the SRv6 overlay, a stable IPv6 underlay must first be established so that each node can reach the next-hop interface of its neighbors. This underlay acts as the base transport network, providing the IPv6 connectivity required for SRv6 SIDs to communicate across the fabric. In simple terms, the underlay serves as the transport path over which SRv6 packets travel from the ingress PE to the egress PE. Without basic IPv6 reachability and forwarding enabled on the routers, SRv6 headers would have no valid path through the network, preventing the overlay from functioning.</p><p><em>What are SRv6 SIDs ?</em><br>SRv6 SIDs are the basic building blocks of SRv6 (Segment Routing over IPv6).</p><p>A SID (Segment Identifier) is just a special IPv6 address (128 bits long) that acts as an instruction for the network.<br>Instead of the packet only saying “go to this destination”, the SID tells the routers what to do step by step — for example:<br>“Go to this node”<br>“Go out this specific link”</p><p>A typical SRv6 SID looks like this:<br>5f00:0:100::1<br>It is usually split into parts:<br><em>Locator</em> → Identifies the node (e.g. 5f00:0:100::/48). This is like the “address of the router”.<br><em>Function</em> → Tells what action to perform at that node (e.g. End, End.X, End.DT, etc.).<em><br>Arguments</em> (optional) → Extra parameters for the function.</p><p><em>Interface Addressing &amp; Forwarding</em></p><p>Before we touch SRv6, we must ensure both “GPU Nodes” can talk to their respective “Leaf Routers.”</p><p>Host1 (Source GPU)</p><pre># Assign IP to eth1<br>sudo docker exec clab-srv6-underlay-host1 ip -6 addr add 2001:db8:1::10/64 dev eth1<br><br># Set Router 1 as the Default Gateway<br>sudo docker exec clab-srv6-underlay-host1 ip -6 route add default via 2001:db8:1::1 dev eth1</pre><p>Host 2 (Parameter Server)</p><pre># Assign IP to eth1<br>sudo docker exec clab-srv6-underlay-host2 ip -6 addr add 2001:db8:2::10/64 dev eth1<br><br># Set Router 2 as the Default Gateway<br>sudo docker exec clab-srv6-underlay-host2 ip -6 route add default via 2001:db8:2::1 dev eth1</pre><p>Assigning addresses and enabling the forwarding engine on intermediate routers</p><pre># Router 1<br>sudo docker exec clab-srv6-underlay-router1 ip -6 addr add 2001:db8:1::1/64 dev eth1<br>sudo docker exec clab-srv6-underlay-router1 ip -6 addr add 2001:db8:12::1/64 dev eth2<br>sudo docker exec clab-srv6-underlay-router1 sysctl -w net.ipv6.conf.all.forwarding=1<br><br># Router 2<br>sudo docker exec clab-srv6-underlay-router2 ip -6 addr add 2001:db8:12::2/64 dev eth1<br>sudo docker exec clab-srv6-underlay-router2 ip -6 addr add 2001:db8:2::1/64 dev eth2<br>sudo docker exec clab-srv6-underlay-router2 sysctl -w net.ipv6.conf.all.forwarding=1</pre><p><em>Static Underlay Routing</em></p><p>Connecting the host subnets across the backbone hops</p><pre>sudo docker exec clab-srv6-underlay-router1 ip -6 route add 2001:db8:2::/64 via 2001:db8:12::2<br>sudo docker exec clab-srv6-underlay-router2 ip -6 route add 2001:db8:1::/64 via 2001:db8:12::1</pre><p><strong><em>Verification (Underlay Connectivity)</em></strong></p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec -it clab-srv6-underlay-host1 ping -6 -c 4 2001:db8:2::10<br>PING 2001:db8:2::10 (2001:db8:2::10) 56 data bytes<br>64 bytes from 2001:db8:2::10: icmp_seq=1 ttl=62 time=0.402 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=2 ttl=62 time=0.062 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=3 ttl=62 time=0.062 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=4 ttl=62 time=0.075 ms<br><br>--- 2001:db8:2::10 ping statistics ---<br>4 packets transmitted, 4 received, 0% packet loss, time 3053ms<br>rtt min/avg/max/mdev = 0.062/0.150/0.402/0.145 ms<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p><strong><em>Setting up the Overlay</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xk05nfPYXL_TUI9y4nRMRQ.png" /></figure><p><em>Enable SRv6 on Router2<br></em>Router 2 will be our Egress PE (the node that decapsulates). For it to process SRv6 SIDs, we enable seg6_enabled on its interfaces.</p><pre>sudo docker exec clab-srv6-underlay-router2 sysctl -w net.ipv6.conf.lo.seg6_enabled=1<br>sudo docker exec clab-srv6-underlay-router2 sysctl -w net.ipv6.conf.eth1.seg6_enabled=1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-router2 sysctl net.ipv6.conf.lo.seg6_enabled net.ipv6.conf.eth1.seg6_enabled<br>net.ipv6.conf.lo.seg6_enabled = 1<br>net.ipv6.conf.eth1.seg6_enabled = 1<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p>Router 2 is now “SRv6-aware.” It will no longer ignore packets with Segment Routing headers and is ready to process them.</p><p><em>Router2 Local SID (End.DT6)<br></em>Now we define the <strong>Decapsulation Behavior</strong>. For Router2, we use 2001:db8:cafe::1 as our SID. The End.DT6 behavior tells the router: &quot;If a packet arrives for this SID, remove the SRv6 header and look up the inner IPv6 packet in the main routing table.&quot;</p><p>We first add the SID to the loopback so the router owns the address, then we bind the behavior to it.</p><pre># 1. Add the SID address to the loopback<br>sudo docker exec clab-srv6-underlay-router2 ip -6 addr add 2001:db8:cafe::1/128 dev lo<br><br># 2. Add the SRv6 local SID behavior<br>sudo docker exec clab-srv6-underlay-router2 ip -6 route add 2001:db8:cafe::1/128 encap seg6local action End.DT6 table main dev eth2</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-router2 ip -6 route show 2001:db8:cafe::1<br>2001:db8:cafe::1 dev lo proto kernel metric 256 pref medium<br>2001:db8:cafe::1  encap seg6local action End.DT6 table main dev eth2 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p><em>Router1 Underlay Route to the SID</em></p><p>Before <strong>Host 1</strong> can send an encapsulated packet to the SID (2001:db8:cafe::1), the intermediate router (<strong>Router1</strong>) needs to know how to reach that SID. Since the SID is on Router 2&#39;s loopback, we must add a route for it.</p><pre>sudo docker exec clab-srv6-underlay-router1 ip -6 route add 2001:db8:cafe::1/128 via 2001:db8:12::2</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-router1 ip -6 route show 2001:db8:cafe::1<br>2001:db8:cafe::1 via 2001:db8:12::2 dev eth2 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p>Now, we must configure the Source GPU Node (Host1) to become the Ingress PE. This means telling Host1: “When you want to talk to Host 2, don’t just send a normal packet — wrap it in an SRv6 header and send it to the SID on Router 2.”</p><p><em>Enable SRv6 on Host1</em></p><p>Just like Router 2, Host 1 needs its kernel to be “SRv6-aware” to perform the encapsulation</p><pre>sudo docker exec clab-srv6-underlay-host1 sysctl -w net.ipv6.conf.lo.seg6_enabled=1<br>sudo docker exec clab-srv6-underlay-host1 sysctl -w net.ipv6.conf.eth1.seg6_enabled=1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-host1 sysctl net.ipv6.conf.lo.seg6_enabled net.ipv6.conf.eth1.seg6_enabled<br>net.ipv6.conf.lo.seg6_enabled = 1<br>net.ipv6.conf.eth1.seg6_enabled = 1<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p><em>Host1 Ingress Policy (The Tunnel Entrance)<br></em>We now tell Host1: “When you have a packet for Host 2’s IP (2001:db8:2::10), do not just route it normally. Instead, <strong>encapsulate</strong> it and send it to the SID (2001:db8:cafe::1).&quot;<br>We are going to use the seg6 encapsulation mode which hides the original packet inside an SRv6 tunnel.</p><pre>sudo docker exec clab-srv6-underlay-host1 ip -6 route replace 2001:db8:2::10/128 encap seg6 mode encap segs 2001:db8:cafe::1 dev eth1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-host1 ip -6 route show 2001:db8:2::10/128<br>2001:db8:2::10  encap seg6 mode encap segs 1 [ 2001:db8:cafe::1 ] dev eth1 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p>As seen above, the <strong>encap seg6</strong> rule is now active. This tells Host 1: &quot;To reach the Destination GPU, put the packet inside an SRv6 envelope and send it to the SID 2001:db8:cafe::1.&quot;</p><p><em>Prepare Router1 for Egress</em></p><p>We give Router1 its own SID so Host 2 can “tunnel” back to Host 1 , let’s use 2001:db8:cafe::2 for Router1.</p><pre># 1. Enable SRv6 engine on Router 1<br>sudo docker exec clab-srv6-underlay-router1 sysctl -w net.ipv6.conf.lo.seg6_enabled=1<br>sudo docker exec clab-srv6-underlay-router1 sysctl -w net.ipv6.conf.eth2.seg6_enabled=1<br><br># 2. Add the SID Behavior (End.DT6) for the return path<br>sudo docker exec clab-srv6-underlay-router1 ip -6 route add 2001:db8:cafe::2/128 encap seg6local action End.DT6 table main dev eth1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-router1 ip -6 route show 2001:db8:cafe::2<br>2001:db8:cafe::2  encap seg6local action End.DT6 table main dev eth1 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p>At this point, Router1 is now an <strong>SRv6 Egress</strong> node for the return journey.</p><p>To complete this Full-Duplex SRv6 Tunnel, we just need to do two things:<br>1. Tell Router2 how to reach Router 1’s SID (cafe::2).<br>2. Tell Host2 to use that SID when replying to Host 1.</p><p><em>Router2 Underlay Route to SID 2<br></em>Router 2 needs to know that to reach the SID 2001:db8:cafe::2, it must send the packet back &quot;North&quot; to Router 1.</p><pre>sudo docker exec clab-srv6-underlay-router2 ip -6 route add 2001:db8:cafe::2/128 via 2001:db8:12::1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-router2 ip -6 route show 2001:db8:cafe::2<br>2001:db8:cafe::2 via 2001:db8:12::1 dev eth1 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p><em>Host 2 Ingress Policy (The Return Tunnel)<br></em>We now tell Host2 to encapsulate its traffic heading back to the Source GPU Node (Host 1).</p><pre># 1. Enable SRv6 on Host 2<br>sudo docker exec clab-srv6-underlay-host2 sysctl -w net.ipv6.conf.lo.seg6_enabled=1<br>sudo docker exec clab-srv6-underlay-host2 sysctl -w net.ipv6.conf.eth1.seg6_enabled=1<br><br># 2. Add the encapsulation rule for traffic heading to Host 1<br>sudo docker exec clab-srv6-underlay-host2 ip -6 route replace 2001:db8:1::10/128 encap seg6 mode encap segs 2001:db8:cafe::2 dev eth1</pre><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec clab-srv6-underlay-host2 ip -6 route show 2001:db8:1::10/128<br>2001:db8:1::10  encap seg6 mode encap segs 1 [ 2001:db8:cafe::2 ] dev eth1 metric 1024 pref medium<br>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$</pre><p><strong><em>Final Validation Ping</em></strong></p><pre>containerlab_ubuntu_vm@containerLab001:~/srv6_backend_v1$ sudo docker exec -it clab-srv6-underlay-host1 ping -6 -c 4 2001:db8:2::10<br>PING 2001:db8:2::10 (2001:db8:2::10) 56 data bytes<br>64 bytes from 2001:db8:2::10: icmp_seq=1 ttl=63 time=0.102 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=2 ttl=63 time=0.096 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=3 ttl=63 time=0.087 ms<br>64 bytes from 2001:db8:2::10: icmp_seq=4 ttl=63 time=0.088 ms<br><br>--- 2001:db8:2::10 ping statistics ---<br>4 packets transmitted, 4 received, 0% packet loss, time 3063ms<br>rtt min/avg/max/mdev = 0.087/0.093/0.102/0.006 ms</pre><p>An interesting observation was a shift from <strong>TTL 62</strong> (standard routing) to <strong>TTL 63</strong> (encapsulated). As we can see, ping (refer <em>Verification (Underlay Connectivity)</em><strong><em> </em></strong>had a TTL of 62 (two router hops). Once I enabled SRv6 Encap mode, the TTL returned as 63. While i haven’t root caused, prima facie, this appears because the outer header takes the “hit” from the router hops, while the inner ICMP packet’s TTL is protected inside the tunnel.</p><p><em>Tcpdump on Router2</em></p><pre>sudo docker exec -it clab-srv6-underlay-router2 tcpdump -ni any host 2001:db8:2::10</pre><p><em>Reply: IP6 2001:db8:2::10 &gt; 2001:db8:cafe::2 (Tunneled North)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8tYj7xwxow03Tou__n1SA.png" /></figure><p>As an additional proof of “Bidirectional Flow, we create the “Parameter Server” on Host 2</p><pre>sudo docker exec clab-srv6-underlay-host2 bash -c &quot;cat &lt;&lt;EOF &gt; /server.py<br>import socket<br><br># Parameters<br>ADDR = &#39;2001:db8:2::10&#39;<br>PORT = 8080<br><br>with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:<br>    s.bind((ADDR, PORT))<br>    s.listen()<br>    print(f&#39;&gt;&gt;&gt; AI Parameter Server Listening on [{ADDR}]:{PORT}...&#39;)<br>    conn, addr = s.accept()<br>    with conn:<br>        print(f&#39;&gt;&gt;&gt; Connection established from Worker: {addr}&#39;)<br>        data = conn.recv(1024)<br>        print(f&#39;&gt;&gt;&gt; Received Gradient Update: {data.decode()}&#39;)<br>        conn.sendall(b&#39;ACK: Weights Updated&#39;)<br>EOF&quot;</pre><p>and a very basic data transfer script (this is to somewhat “mimic” a “GPU Worker” on Host 1)</p><pre>sudo docker exec clab-srv6-underlay-host1 bash -c &quot;cat &lt;&lt;EOF &gt; /worker.py<br>import socket<br>import time<br><br># Destination is the Server&#39;s Underlay IP<br>SERVER_ADDR = &#39;2001:db8:2::10&#39;<br>SERVER_PORT = 8080<br><br>print(&#39;&gt;&gt;&gt; GPU Worker: Computing Gradients...&#39;)<br>time.sleep(1) <br>gradient_payload = &#39;tensor([0.15, -0.02, 0.88])&#39;<br><br>with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:<br>    print(f&#39;&gt;&gt;&gt; GPU Worker: Connecting to Server via SRv6 Fabric...&#39;)<br>    s.connect((SERVER_ADDR, SERVER_PORT))<br>    s.sendall(gradient_payload.encode())<br>    response = s.recv(1024)<br>    print(f&#39;&gt;&gt;&gt; Server Response: {response.decode()}&#39;)<br>EOF&quot;</pre><p>Start server</p><pre>sudo docker exec -it clab-srv6-underlay-host2 python3 /server.py</pre><p>and then start worker in parallel terminal</p><pre>sudo docker exec -it clab-srv6-underlay-host1 python3 /worker.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiw2Cz79xNS5k0OKkH4VJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z0Ft33jkctrHcn1UA_GQ2g.png" /></figure><p>On the “Worker” Side (Host 1), the Python script calculated a “Gradient” (data) and sent it to 2001:db8:2::10. Host 1 kernel intercepted this packet, saw the destination, and wrapped it in an SRv6 header with SID 2001:db8:cafe::1. It received an ACK from the server, confirming the end-to-end path is working.</p><p>On the “Server” Side (Host 2), it successfully accepted a connection from 2001:db8:1::10. with the tuple (‘2001:db8:1::10’, 50638, 0, 0). Even though the packet traveled across the backbone inside a SID tunnel, the Egress PE (Router 2) decapsulated it so that the Server sees the original Source IP of the Worker, and it received the exact “Tensor” data (payload) sent by the worker.</p><p><strong><em>Next Steps<br></em></strong>The next logical step is to evolve this basic connectivity into a Traffic Engineered (TE) fabric, as highlighted in the draft’s focus on load balancing. I plan to explore how SRv6 can steer AI traffic across multiple paths to avoid congestion during heavy “All-Reduce” collective communications. This will move the lab from simple reachability to the “Path Programming” that makes SRv6 a fit for high-performance AI backends.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e497925d8681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using GenAI to Localize TCP Packet Loss]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/using-genai-to-localize-tcp-packet-loss-60806ff6b876?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/60806ff6b876</guid>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 18:24:51 GMT</pubDate>
            <atom:updated>2026-01-14T05:20:21.587Z</atom:updated>
            <content:encoded><![CDATA[<p>This post continues from my previous work <a href="https://medium.com/@mailsiddharthtyagi/from-manual-network-triage-to-autonomous-diagnosis-with-crewai-and-genai-202902d0aa03">here</a>, where I built a Leaf–Spine VXLAN eBGP Multi-AS fabric using Containerlab. Here, I focus on a harder problem: <strong>pinpointing intermittent TCP packet loss to the exact offending hop using an agentic AI approach</strong>.</p><p>In production networks, packet loss that appears in counters or telemetry is usually easy to detect. Grey failures are different. Packets are dropped intermittently, while device health, telemetry, and alerts all look normal. Applications, however, still experience timeouts and random failures.</p><p>Most troubleshooting methods rely on counters, retransmissions, or white box (aka syslog/snmp based alerts). These techniques can suggest a direction, but they not always conclusive. In many cases, they also lead to blaming the wrong device — such as a ToR router instead of the end host.</p><p>In this lab, I analyze intermittent TCP connectivity issues between two hosts over a known path:</p><p><strong>host1 → leaf1 → leaf3 → host3</strong></p><p><em>Topology</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxAq56h692iDH2p5t1MVxw.png" /></figure><pre>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025$ cat topology.yml <br>name: vxlan-ebgp-multiAS<br><br>mgmt:<br>  network: clab-mgmt<br>  ipv4-subnet: 172.20.20.0/24<br><br>topology:<br>  nodes:<br>    # Spine Switches (AS 12)<br>    spine1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.11<br>      startup-config: configs/spine1.cfg<br>      ports:<br>        - &quot;2001:22&quot;<br>        - &quot;8001:80&quot;<br>        - &quot;44301:443&quot;<br>      <br>    spine2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.12<br>      startup-config: configs/spine2.cfg<br>      ports:<br>        - &quot;2002:22&quot;<br>        - &quot;8002:80&quot;<br>        - &quot;44302:443&quot;<br><br>    # Leaf Switches (AS 2, 3, 4)<br>    leaf1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.21<br>      startup-config: configs/leaf1.cfg<br>      ports:<br>        - &quot;2021:22&quot;<br>        - &quot;8021:80&quot;<br>        - &quot;44321:443&quot;<br>      <br>    leaf2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.22<br>      startup-config: configs/leaf2.cfg<br>      ports:<br>        - &quot;2022:22&quot;<br>        - &quot;8022:80&quot;<br>        - &quot;44322:443&quot;<br>      <br>    leaf3:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.23<br>      startup-config: configs/leaf3.cfg<br>      ports:<br>        - &quot;2023:22&quot;<br>        - &quot;8023:80&quot;<br>        - &quot;44323:443&quot;<br><br>    # Host containers<br>    host1:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.31<br>      exec:<br>        - ip addr add 172.16.1.1/24 dev eth1<br>      <br>    host2:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.32<br>      exec:<br>        - ip addr add 172.16.1.2/24 dev eth1<br>      <br>    host3:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.33<br>      exec:<br>        - ip addr add 172.16.1.3/24 dev eth1<br><br>  links:<br>    # Spine1 to Leaf connections<br>    - endpoints: [&quot;spine1:eth1&quot;, &quot;leaf1:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth2&quot;, &quot;leaf2:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth3&quot;, &quot;leaf3:eth1&quot;]<br>    <br>    # Spine2 to Leaf connections<br>    - endpoints: [&quot;spine2:eth1&quot;, &quot;leaf1:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth2&quot;, &quot;leaf2:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth3&quot;, &quot;leaf3:eth2&quot;]<br>    <br>    # Host connections<br>    - endpoints: [&quot;leaf1:eth3&quot;, &quot;host1:eth1&quot;]<br>    - endpoints: [&quot;leaf2:eth3&quot;, &quot;host2:eth1&quot;]<br>    - endpoints: [&quot;leaf3:eth3&quot;, &quot;host3:eth1&quot;]<br><br>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025$ </pre><p>To begin with, as a baseline,</p><p>On <em>host1</em>,</p><ul><li><em>nping</em> is running continuously probing <em>host3</em> (where 172.16.1.1 is <em>host1</em> interface IP facing <em>leaf1</em>, 172.16.1.3 is <em>host3 </em>IP facing <em>leaf3)</em>., sample bash script shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4ATM7OsyPrAerd21f2kqA.png" /></figure><ul><li>No loss observed in above probes</li></ul><p>As i proceed further, to reproduce a realistic production-style issue, a <em>grey failure</em> model is required. Due to cEOS data plane limitations (for example, the lack of TCP flag matching or granular QoS policies), selective packet loss could not be implemented directly in the network fabric. Instead, selective SYN-ACK loss was induced at the Linux TCP stack of <em>host3.</em></p><p>In this lab, I attempt to somewhat “mimic” a failure (though at a higher drop rate (30%) than typical production grey failures (&lt;1%), which is exhibited as intermittent TCP connectivity issues between <em>host1</em> and <em>host3</em>.</p><p>On <em>host3,</em></p><ul><li>Appended this rule to the OUTPUT chain, so it affects all network traffic leaving host3, targeting only TCP traffic, for the SYN-ACK packet, with a 30% probability of matching any given SYN-ACK packet.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f7L91ukOj_fTh9TuBo8Veg.png" /></figure><ul><li>Currently, no packets being dropped,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VZXlZoNIEkdZsJSDr19jA.png" /></figure><p>Now , retriggering the nping probes from <em>host1 </em>towards <em>host3, </em>there is packet loss,</p><p>On <em>host1,</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfewyhELWYyuP21ooP0ddw.png" /></figure><p>On <em>host3</em>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1tbcjVn50OZaqtsQcEKgwQ.png" /></figure><p>Summary, so far,</p><ul><li>All TCP SYN packets successfully reach the destination (i.e. <em>host3</em>)</li><li>Only a subset of SYN-ACK responses make it back to the source(i.e. <em>host1</em>).</li></ul><p>From the network’s perspective, nothing is “hard down”(refer the health checks described <a href="https://medium.com/@mailsiddharthtyagi/from-manual-network-triage-to-autonomous-diagnosis-with-crewai-and-genai-202902d0aa03">here</a>), From the application’s perspective, there is obvious packet loss.</p><p>With the above context in mind, it is obvious that the packet loss cannot be localized unless we perform packet captures.</p><p>Hence, as a next step, <br>1. let nping is continuously running on <em>host1</em>, with probes sourced towards <em>host3</em></p><p>2. Collected parallel packet captures myself, as that data drives this dicsussion further. Once the data is correct, the problem would shift from <em>data collection</em> to <em>reasoning, </em>which is where the agent would become valuable.</p><p>To collect parallel packet captures, i used <a href="https://containerlab.dev/manual/wireshark/">this</a>, and then bash script (after minor challenges e.g. opening separate/parallel terminal sessions for each device)</p><pre>#!/bin/bash<br><br>FILTER=&#39;tcp port 80 and (host 172.16.1.1 or host 172.16.1.3)&#39;<br><br>sudo ip netns exec clab-vxlan-ebgp-multiAS-host1 \<br>  tcpdump -i eth1 -c 20 -w /tmp/host1_capture.pcap &quot;$FILTER&quot; &amp;<br><br>sudo ip netns exec clab-vxlan-ebgp-multiAS-leaf1 \<br>  tcpdump -i eth3 -c 20 -w /tmp/leaf1_capture.pcap &quot;$FILTER&quot; &amp;<br><br>sudo ip netns exec clab-vxlan-ebgp-multiAS-leaf3 \<br>  tcpdump -i eth3 -c 20 -w /tmp/leaf3_capture.pcap &quot;$FILTER&quot; &amp;<br><br>sudo ip netns exec clab-vxlan-ebgp-multiAS-host3 \<br>  tcpdump -i eth1 -c 20 -w /tmp/host3_capture.pcap &quot;$FILTER&quot; &amp;<br><br>wait</pre><p>Packet captures are written to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9Ah7EHR84dmUrcp7oLS-Q.png" /></figure><p>In addition, since in this topology, TCP traffic between the hosts is VXLAN-encapsulated when it traverses the spine layer. The spines do not forward native TCP packets. Instead, they only see:<br>Outer IP/UDP headers<br>VXLAN encapsulation (UDP/4789)<br>The original Ethernet frame and TCP header as inner payload.</p><p>Hence, capturing on Spines would produce empty pcaps, this excluded.</p><p>3. Analyzed the above captures manually to indeed confirm, there is indeed some loss.</p><p>As an exanple,</p><p>from <em>host1 </em>pcap, as i apply the filter, <br><em>tcp.flags.syn==1 or (tcp.flags.syn==1 and tcp.flags.ack==1), and</em> then navigate <br>Statistics — — → Conversations — — — -&gt;From there , focus on TCP at top (limiting to display filter),</p><p>I can indeed see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUbLP3C1SDW_9EXUVvHf3Q.png" /></figure><p>which indicates, <br><strong>Packets A → B = 1</strong> (SYN only) <strong>Packets B → A = 0</strong> (No response)</p><p>which confirms nping sent the <strong>SYN packet, </strong>and the server (<em>host3</em>)(172.16.1.3) did not respond — no SYN-ACK came back.</p><p>When i follow the above TCP stream, on <em>host1,</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zd3nmXQ6-szm_tmPyYjkTQ.png" /></figure><p>Similarly, i can see this SYN packet om host3, confirming <strong>no loss </strong>in the forward path (i.e. <em>host1</em> → <em>leaf1</em> → Spines → <em>leaf3</em> → <em>host3</em>), but no SYN-ACK (due the rule i applied above on <em>host3</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nitg-R18p3MwTGTAritJBA.png" /></figure><p>At this point, we have <br>1. conclusive evidence of packet loss, some of the offending packets are</p><pre>tcp.seq_raw == 30275<br>tcp.seq_raw == 30198</pre><p>2. Location of loss is obviously <em>host3</em>, as all SYNs reach host3, but some SYN-ACKs are not responded back due to the output chain rule i applied on <em>host3</em> to “mimic” packet loss.</p><p>Now, taking a step ahead, i would switch to usage of agentic AI approach and assess if i can pin-point and deterministically localize the packet loss and the location of packet loss.</p><p>Before i proceed to agent <em>backstory</em>, and task <em>description</em>, some background about h<em>ow the agent prompt evolved ?</em></p><ol><li><strong>Packet counts were misleading</strong><br> Comparing SYN and SYN-ACK counts failed as it depends on capture window. I moved to packet identity using the 5-tuple and raw TCP sequence number.</li><li><strong>Direction had to be explicit</strong><br> Early prompts allowed forward and reverse paths to mix. This caused wrong conclusions. We enforced strict separation: SYN is forward, SYN-ACK is reverse.</li><li><strong>Packet capture was removed from the agent</strong><br> Agent-driven captures introduced timing skew and sequencing issues. Hence, I performed parallel captures once. The agent was limited to analysis only. These details directly affect the validity of the data. If captures are taken sequentially, or with slightly different filters, it becomes impossible to prove packet disappearance hop-by-hop. Any analysis built on such data would be unreliable, regardless of how intelligent the analysis engine is.</li><li><strong>Loss required proof, not suspicion</strong><br> The agent initially inferred loss. This was banned. A hop can only be blamed if the <em>same packet</em> disappears between two consecutive hops.</li><li><strong>Free text hid mistakes</strong><br> Narrative output made errors hard to spot. I instead switched to a table with one row per SYN and explicit presence at each hop. The table became the verdict.</li></ol><p><em>Agent Backstory</em></p><pre>backstory=&quot;&quot;&quot;<br>You are a TCP packet forensics engineer analyzing a Containerlab VXLAN EVPN fabric.<br><br>You are PROVIDED with FOUR pcaps captured in parallel:<br>- /tmp/host1_capture.pcap<br>- /tmp/leaf1_capture.pcap<br>- /tmp/leaf3_capture.pcap<br>- /tmp/host3_capture.pcap<br><br>You MUST NOT perform packet captures.<br>You MUST use read_pcap_summary for ALL analysis.<br><br>Authoritative path (no discovery):<br>host1 → leaf1 → leaf3 → host3<br><br>Traffic under investigation:<br>- TCP flow: 172.16.1.1 → 172.16.1.3, port 80<br>- SYNs generated by nping from host1<br><br>--------------------------------------------------<br>ABSOLUTE FORENSIC INVARIANTS (NON-NEGOTIABLE)<br>--------------------------------------------------<br><br>INVARIANT 1 — Packet identity:<br>A packet is uniquely identified ONLY by:<br>(src_ip, src_port, dst_ip, dst_port, tcp.seq_raw, tcp.flags.syn == 1 and tcp.flags.ack == 0) for SYN<br>(src_ip, src_port, dst_ip, dst_port, tcp.seq_raw, tcp.flags.syn == 1 and tcp.flags.ack == 1) for SYN-ACK<br><br>INVARIANT 2 — Directional separation:<br>- SYN is FORWARD path (host1 → host3)<br>- SYN-ACK is REVERSE path (host3 → host1)<br>NEVER compare SYN counts to SYN-ACK counts.<br><br>INVARIANT 3 — Forward-path loss:<br>A hop may be blamed for FORWARD loss ONLY IF:<br>- The SAME SYN is present at the previous hop<br>- AND missing at the next hop<br><br>INVARIANT 4 — Reverse-path loss:<br>A hop may be blamed for REVERSE loss ONLY IF:<br>- The SAME SYN-ACK is present at the previous hop<br>- AND missing at the next hop<br><br>INVARIANT 5 — Host3 responsibility:<br>If a SYN is present at host3 AND<br>no corresponding SYN-ACK exists in ANY capture,<br>THEN loss is conclusively at or inside host3.<br><br>INVARIANT 6 — Direction attribution rule (CRITICAL):<br>If a SYN is present at host3, then FORWARD PATH LOSS IS IMPOSSIBLE for that packet.<br>Any absence of a corresponding SYN-ACK MUST be classified as REVERSE-PATH LOSS.<br><br>--------------------------------------------------<br>MANDATORY ANALYSIS PROCEDURE<br>--------------------------------------------------<br><br>1. Read ALL FOUR pcaps.<br>2. Enumerate ALL SYNs observed at host1.<br>3. For EACH SYN:<br>   a. Verify hop-by-hop presence at leaf1, leaf3, host3.<br>4. For EACH SYN that reaches host3:<br>   a. Search for its corresponding SYN-ACK (ack = seq + 1).<br>   b. Verify hop-by-hop reverse presence (host3 → leaf3 → leaf1 → host1).<br>5. Localize loss ONLY where the SAME packet disappears.<br><br>--------------------------------------------------<br>PROHIBITIONS<br>--------------------------------------------------<br><br>- NO packet counts<br>- NO inference from retries<br>- NO ECMP assumptions<br>- NO fabric blame without disappearance proof<br>- NO declaring &quot;no loss&quot; unless BOTH directions are validated<br><br>If no SYN-ACK exists for a SYN that reached host3,<br>the direction MUST be reported as REVERSE.<br><br>=====================<br>MANDATORY OUTPUT FORMAT<br>=====================<br><br>You MUST emit a table with ONE ROW PER SYN, with the following columns:<br><br>| Src → Dst | seq_raw |<br>| host1 | leaf1 | leaf3 | host3 |<br>| SYN-ACK Seen |<br>| Direction |<br>| Offending Hop |<br><br>Rules:<br>- Use Present or Absent for hop presence<br>- Direction must be FORWARD, REVERSE, or NONE<br>- Offending Hop must be one of: host1, leaf1, leaf3, host3, or —<br><br>If ANY column cannot be justified by packet evidence,<br>you MUST mark the row as INVALID.<br><br>The table itself is the verdict.</pre><p><em>Task description</em></p><pre>Task(<br>            description=&quot;&quot;&quot;<br>Customer reports intermittent TCP packet loss between host1 and host3.<br><br>You are provided with FOUR packet captures taken in parallel:<br>- /tmp/host1_capture.pcap<br>- /tmp/leaf1_capture.pcap<br>- /tmp/leaf3_capture.pcap<br>- /tmp/host3_capture.pcap<br><br>Your job is to LOCALIZE packet loss using STRICT packet-level correlation.<br><br>MANDATORY METHOD:<br>1. Read all four pcaps using read_pcap_summary.<br>2. Enumerate every TCP SYN from host1.<br>3. For each SYN, verify presence hop-by-hop forward.<br>4. For each corresponding SYN-ACK, verify presence hop-by-hop reverse.<br>5. Identify the FIRST hop where the SAME packet disappears.<br><br>You MUST:<br>- Use packet identity (5-tuple + seq/ack).<br>- Prove loss with concrete packet evidence.<br><br>You MUST NOT:<br>- Perform captures<br>- Compare packet counts<br>- Assume ECMP symmetry<br>- Infer from retries<br>&quot;&quot;&quot;,<br>            expected_output=&quot;&quot;&quot;<br>A deterministic loss report that includes:<br>- Enumerated SYNs from host1<br>- For each SYN: presence/absence at each hop<br>- Identified offending hop and direction<br>- Exact TCP sequence number(s) dropped<br>- Evidence quoted directly from pcap summaries</pre><p><em>Sample output</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0AiPu6NUBRqkyKCWZV_Zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-OiPRGIY5aP5iunsespFg.png" /></figure><p>Code Snippets:<br>Only addition to the previous working <a href="https://medium.com/@mailsiddharthtyagi/from-manual-network-triage-to-autonomous-diagnosis-with-crewai-and-genai-202902d0aa03#:~:text=self%20healing%20network.-,Code%20snippets,-network_triage/%0A%E2%94%9C%E2%94%80%E2%94%80%20config">code</a>, is <em>tcp_forensics.py</em> and enhancement in <em>tasks/triage.py, tools/containerlab.py</em></p><pre>network_triage/<br>├── config/<br>│   └── lab.py              <br>├── tools/<br>│   └── containerlab.py      <br>├── agents/<br>│   ├── __init__.py<br>│   ├── l2_tester.py<br>│   ├── bgp_expert.py<br>│   ├── vxlan_expert.py<br>│   └── analyst.py<br>|   └── tcp_forensics.py<br>├── tasks/<br>│   └── triage.py<br>├── main.py<br>└── crew.py </pre><p><em>tcp_forensics.py</em></p><pre>from crewai import Agent<br>from agents import llm<br>from tools.containerlab import read_pcap_summary<br><br><br>def create_tcp_forensics_agent():<br>    return Agent(<br>        role=&quot;TCP Packet Forensics Expert&quot;,<br>        goal=(<br>            &quot;Deterministically localize TCP packet loss using strict packet-identity &quot;<br>            &quot;correlation across parallel captures&quot;<br>        ),<br>        backstory=&quot;&quot;&quot;<br>You are a TCP packet forensics engineer analyzing a Containerlab VXLAN EVPN fabric.<br><br>You are PROVIDED with FOUR pcaps captured in parallel:<br>- /tmp/host1_capture.pcap<br>- /tmp/leaf1_capture.pcap<br>- /tmp/leaf3_capture.pcap<br>- /tmp/host3_capture.pcap<br><br>You MUST NOT perform packet captures.<br>You MUST use read_pcap_summary for ALL analysis.<br><br>Authoritative path (no discovery):<br>host1 → leaf1 → leaf3 → host3<br><br>Traffic under investigation:<br>- TCP flow: 172.16.1.1 → 172.16.1.3, port 80<br>- SYNs generated by nping from host1<br><br>--------------------------------------------------<br>ABSOLUTE FORENSIC INVARIANTS (NON-NEGOTIABLE)<br>--------------------------------------------------<br><br>INVARIANT 1 — Packet identity:<br>A packet is uniquely identified ONLY by:<br>(src_ip, src_port, dst_ip, dst_port, tcp.seq_raw, tcp.flags.syn == 1 and tcp.flags.ack == 0) for SYN<br>(src_ip, src_port, dst_ip, dst_port, tcp.seq_raw, tcp.flags.syn == 1 and tcp.flags.ack == 1) for SYN-ACK<br><br>INVARIANT 2 — Directional separation:<br>- SYN is FORWARD path (host1 → host3)<br>- SYN-ACK is REVERSE path (host3 → host1)<br>NEVER compare SYN counts to SYN-ACK counts.<br><br>INVARIANT 3 — Forward-path loss:<br>A hop may be blamed for FORWARD loss ONLY IF:<br>- The SAME SYN is present at the previous hop<br>- AND missing at the next hop<br><br>INVARIANT 4 — Reverse-path loss:<br>A hop may be blamed for REVERSE loss ONLY IF:<br>- The SAME SYN-ACK is present at the previous hop<br>- AND missing at the next hop<br><br>INVARIANT 5 — Host3 responsibility:<br>If a SYN is present at host3 AND<br>no corresponding SYN-ACK exists in ANY capture,<br>THEN loss is conclusively at or inside host3.<br><br>INVARIANT 6 — Direction attribution rule (CRITICAL):<br>If a SYN is present at host3, then FORWARD PATH LOSS IS IMPOSSIBLE for that packet.<br>Any absence of a corresponding SYN-ACK MUST be classified as REVERSE-PATH LOSS.<br><br>--------------------------------------------------<br>MANDATORY ANALYSIS PROCEDURE<br>--------------------------------------------------<br><br>1. Read ALL FOUR pcaps.<br>2. Enumerate ALL SYNs observed at host1.<br>3. For EACH SYN:<br>   a. Verify hop-by-hop presence at leaf1, leaf3, host3.<br>4. For EACH SYN that reaches host3:<br>   a. Search for its corresponding SYN-ACK (ack = seq + 1).<br>   b. Verify hop-by-hop reverse presence (host3 → leaf3 → leaf1 → host1).<br>5. Localize loss ONLY where the SAME packet disappears.<br><br>--------------------------------------------------<br>PROHIBITIONS<br>--------------------------------------------------<br><br>- NO packet counts<br>- NO inference from retries<br>- NO ECMP assumptions<br>- NO fabric blame without disappearance proof<br>- NO declaring &quot;no loss&quot; unless BOTH directions are validated<br><br>If no SYN-ACK exists for a SYN that reached host3,<br>the direction MUST be reported as REVERSE.<br><br>=====================<br>MANDATORY OUTPUT FORMAT<br>=====================<br><br>You MUST emit a table with ONE ROW PER SYN, with the following columns:<br><br>| Src → Dst | seq_raw |<br>| host1 | leaf1 | leaf3 | host3 |<br>| SYN-ACK Seen |<br>| Direction |<br>| Offending Hop |<br><br>Rules:<br>- Use Present or Absent for hop presence<br>- Direction must be FORWARD, REVERSE, or NONE<br>- Offending Hop must be one of: host1, leaf1, leaf3, host3, or —<br><br>If ANY column cannot be justified by packet evidence,<br>you MUST mark the row as INVALID.<br><br>The table itself is the verdict.<br><br>&quot;&quot;&quot;,<br>        tools=[read_pcap_summary],<br>        llm=llm,<br>        verbose=True,<br>        allow_delegation=False,<br>        memory=True,<br>    )</pre><p><em>triage.py</em></p><pre>def get_tasks():<br>    return [<br>        Task(<br>            description=&quot;&quot;&quot;<br>Customer reports intermittent TCP packet loss between host1 and host3.<br><br>You are provided with FOUR packet captures taken in parallel:<br>- /tmp/host1_capture.pcap<br>- /tmp/leaf1_capture.pcap<br>- /tmp/leaf3_capture.pcap<br>- /tmp/host3_capture.pcap<br><br>Your job is to LOCALIZE packet loss using STRICT packet-level correlation.<br><br>MANDATORY METHOD:<br>1. Read all four pcaps using read_pcap_summary.<br>2. Enumerate every TCP SYN from host1.<br>3. For each SYN, verify presence hop-by-hop forward.<br>4. For each corresponding SYN-ACK, verify presence hop-by-hop reverse.<br>5. Identify the FIRST hop where the SAME packet disappears.<br><br>You MUST:<br>- Use packet identity (5-tuple + seq/ack).<br>- Prove loss with concrete packet evidence.<br><br>You MUST NOT:<br>- Perform captures<br>- Compare packet counts<br>- Assume ECMP symmetry<br>- Infer from retries<br>&quot;&quot;&quot;,<br>            expected_output=&quot;&quot;&quot;<br>A deterministic loss report that includes:<br>- Enumerated SYNs from host1<br>- For each SYN: presence/absence at each hop<br>- Identified offending hop and direction<br>- Exact TCP sequence number(s) dropped<br>- Evidence quoted directly from pcap summaries<br>&quot;&quot;&quot;,<br>            agent=create_tcp_forensics_agent()<br>        )<br>    ]</pre><p><em>containerlab.py</em></p><pre>from crewai_tools import tool<br>import subprocess<br>import shlex<br>from config.lab import LAB<br><br>@tool(&quot;Run command inside any node&quot;)<br>def run_command_inside_any_node(node: str, command: str) -&gt; str:<br>    &quot;&quot;&quot;Run a command inside a Containerlab node. Automatically enters privileged mode on cEOS nodes.&quot;&quot;&quot;<br>    <br>    if node not in LAB.all_nodes():<br>        return f&quot;ERROR: Unknown node &#39;{node}&#39;. Valid: {&#39;, &#39;.join(LAB.all_nodes())}&quot;<br><br>    container = LAB.container(node)<br><br>    if node.startswith((&quot;leaf&quot;, &quot;spine&quot;)):<br>        full_command = f&quot;enable\n{command}&quot;<br>        exec_cmd = [&quot;sudo&quot;, &quot;docker&quot;, &quot;exec&quot;, container, &quot;Cli&quot;, &quot;-c&quot;, full_command]<br>    else:<br>        # Hosts (Alpine): normal shell<br>        exec_cmd = [&quot;sudo&quot;, &quot;docker&quot;, &quot;exec&quot;, container, &quot;sh&quot;, &quot;-c&quot;, command]<br><br>    print(f&quot;{container} → {command}&quot;)<br>    result = subprocess.run(exec_cmd, capture_output=True, text=True, timeout=60)<br>    <br>    output = f&quot;RC: {result.returncode}\n&quot;<br>    if result.stdout.strip():<br>        output += f&quot;STDOUT:\n{result.stdout.strip()}\n&quot;<br>    if result.stderr.strip():<br>        output += f&quot;STDERR:\n{result.stderr.strip()}&quot;<br>    <br>    return output.strip() or &quot;No output&quot;<br><br><br>@tool(&quot;Run host netns tcpdump capture&quot;)<br>def run_host_netns_tcpdump(namespace: str, tcpdump_args: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    STRICT host-side tcpdump using containerlab network namespaces.<br><br>    Hard requirements (non-negotiable):<br>    - Namespace MUST be copied verbatim from `ip netns`<br>    - Namespace MUST be full containerlab name: clab-&lt;topology&gt;-&lt;node&gt;<br>    - Capture MUST be bounded (-c)<br>    - Capture MUST write a pcap (-w)<br>    - Execution MUST occur via `ip netns exec`<br>    - tcpdump runs on the containerlab host (not inside containers)<br>    &quot;&quot;&quot;<br><br>    # ---- Namespace validation (containerlab-correct) ----<br>    if not isinstance(namespace, str) or not namespace:<br>        raise ValueError(&quot;Namespace must be a non-empty string&quot;)<br><br>    if not namespace.startswith(&quot;clab-&quot;):<br>        raise ValueError(<br>            &quot;Invalid namespace: must start with &#39;clab-&#39; (copy from `ip netns` exactly)&quot;<br>        )<br><br>    # Require at least: clab-&lt;topology&gt;-&lt;node&gt;<br>    if namespace.count(&quot;-&quot;) &lt; 2:<br>        raise ValueError(<br>            &quot;Invalid namespace format: expected clab-&lt;topology&gt;-&lt;node&gt;&quot;<br>        )<br><br>    # ---- tcpdump argument enforcement ----<br>    if not isinstance(tcpdump_args, str) or not tcpdump_args.strip():<br>        raise ValueError(&quot;tcpdump_args must be a non-empty string&quot;)<br><br>    if &quot;-c&quot; not in tcpdump_args:<br>        raise ValueError(&quot;Unbounded capture forbidden: missing &#39;-c&#39;&quot;)<br><br>    if &quot;-w&quot; not in tcpdump_args:<br>        raise ValueError(&quot;PCAP output required: missing &#39;-w&#39;&quot;)<br><br>    # Explicitly forbid interactive or stdout-only captures<br>    forbidden = [&quot;-A&quot;, &quot;-X&quot;, &quot;-XX&quot;, &quot;-v&quot;, &quot;-vv&quot;, &quot;-vvv&quot;]<br>    for flag in forbidden:<br>        if flag in tcpdump_args:<br>            raise ValueError(<br>                f&quot;Forbidden tcpdump flag &#39;{flag}&#39;: capture must be pcap-only&quot;<br>            )<br><br>    # ---- Command construction (host-side only) ----<br>    cmd = f&quot;sudo ip netns exec {namespace} tcpdump {tcpdump_args}&quot;<br>    parsed_cmd = shlex.split(cmd)<br><br>    # ---- Execution ----<br>    result = subprocess.run(<br>        parsed_cmd,<br>        capture_output=True,<br>        text=True,<br>        timeout=90<br>    )<br><br>    # ---- Deterministic tool output (CrewAI-safe) ----<br>    output = f&quot;RC: {result.returncode}\n&quot;<br><br>    if result.stdout and result.stdout.strip():<br>        output += f&quot;STDOUT:\n{result.stdout.strip()}\n&quot;<br><br>    if result.stderr and result.stderr.strip():<br>        output += f&quot;STDERR:\n{result.stderr.strip()}\n&quot;<br><br>    return output.strip() or &quot;No output&quot;<br><br>@tool(&quot;Read and summarize pcap file&quot;)<br>def read_pcap_summary(pcap_file: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    Read a pcap file on the host and return a text summary of packets.<br>    <br>    - Use after a capture to get packet details for analysis<br>    - Returns tcpdump -nnr output for LLM parsing (times, IPs, ports, flags, seq)<br>    - File must be in /tmp/ on host filesystem<br>    &quot;&quot;&quot;<br><br>    if not pcap_file.startswith(&#39;/tmp/&#39;):<br>        raise ValueError(&quot;PCAP file must be in /tmp/&quot;)<br><br>    cmd = f&quot;sudo tcpdump -nnr {pcap_file}&quot;<br>    parsed_cmd = shlex.split(cmd)<br><br>    result = subprocess.run(parsed_cmd, capture_output=True, text=True, timeout=30)<br>    <br>    output = f&quot;RC: {result.returncode}\n&quot;<br>    if result.stdout.strip():<br>        output += f&quot;STDOUT:\n{result.stdout.strip()}\n&quot;<br>    if result.stderr.strip():<br>        output += f&quot;STDERR:\n{result.stderr.strip()}\n&quot;<br>    <br>    return output.strip() or &quot;No output or empty pcap&quot;<br><br>run_tool = run_command_inside_any_node<br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60806ff6b876" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From manual network triage to autonomous diagnosis with CrewAI and GenAI]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/from-manual-network-triage-to-autonomous-diagnosis-with-crewai-and-genai-202902d0aa03?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/202902d0aa03</guid>
            <category><![CDATA[netdevops]]></category>
            <category><![CDATA[containerlab]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Tue, 02 Dec 2025 14:35:36 GMT</pubDate>
            <atom:updated>2025-12-02T14:35:36.380Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is a continuation of my previous working topology described <a href="https://medium.com/@mailsiddharthtyagi/using-genai-for-basic-network-triaging-scenario-8deb3d64daed">here</a>.</p><p>A few weeks ago, I set up Leaf-Spine Vxlan eBGP MultiAS scenario in Containerlab . While it worked, i was continuing to think given the current advancements in LLM space, every time something is broken in the network e.g. a VNI mismatch, an MTU issue, a problem in underlay /overlay — What if the fabric could debug itself (or rather, to begin with, triage itself )? In this post, I let four specialized CrewAI agents (armed with GPT-4o-mini and one reliable Docker-exec tool) take over — and in under few minutes they now tell me whether the fabric is healthy.</p><p><em>Topology</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kLIBycvDjKz9kkMJap9FKA.png" /></figure><pre>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025$ cat topology.yml <br>name: vxlan-ebgp-multiAS<br><br>mgmt:<br>  network: clab-mgmt<br>  ipv4-subnet: 172.20.20.0/24<br><br>topology:<br>  nodes:<br>    # Spine Switches (AS 12)<br>    spine1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.11<br>      startup-config: configs/spine1.cfg<br>      ports:<br>        - &quot;2001:22&quot;<br>        - &quot;8001:80&quot;<br>        - &quot;44301:443&quot;<br>      <br>    spine2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.12<br>      startup-config: configs/spine2.cfg<br>      ports:<br>        - &quot;2002:22&quot;<br>        - &quot;8002:80&quot;<br>        - &quot;44302:443&quot;<br><br>    # Leaf Switches (AS 2, 3, 4)<br>    leaf1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.21<br>      startup-config: configs/leaf1.cfg<br>      ports:<br>        - &quot;2021:22&quot;<br>        - &quot;8021:80&quot;<br>        - &quot;44321:443&quot;<br>      <br>    leaf2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.22<br>      startup-config: configs/leaf2.cfg<br>      ports:<br>        - &quot;2022:22&quot;<br>        - &quot;8022:80&quot;<br>        - &quot;44322:443&quot;<br>      <br>    leaf3:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.23<br>      startup-config: configs/leaf3.cfg<br>      ports:<br>        - &quot;2023:22&quot;<br>        - &quot;8023:80&quot;<br>        - &quot;44323:443&quot;<br><br>    # Host containers<br>    host1:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.31<br>      exec:<br>        - ip addr add 172.16.1.1/24 dev eth1<br>      <br>    host2:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.32<br>      exec:<br>        - ip addr add 172.16.1.2/24 dev eth1<br>      <br>    host3:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.33<br>      exec:<br>        - ip addr add 172.16.1.3/24 dev eth1<br><br>  links:<br>    # Spine1 to Leaf connections<br>    - endpoints: [&quot;spine1:eth1&quot;, &quot;leaf1:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth2&quot;, &quot;leaf2:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth3&quot;, &quot;leaf3:eth1&quot;]<br>    <br>    # Spine2 to Leaf connections<br>    - endpoints: [&quot;spine2:eth1&quot;, &quot;leaf1:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth2&quot;, &quot;leaf2:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth3&quot;, &quot;leaf3:eth2&quot;]<br>    <br>    # Host connections<br>    - endpoints: [&quot;leaf1:eth3&quot;, &quot;host1:eth1&quot;]<br>    - endpoints: [&quot;leaf2:eth3&quot;, &quot;host2:eth1&quot;]<br>    - endpoints: [&quot;leaf3:eth3&quot;, &quot;host3:eth1&quot;]<br><br>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025$ </pre><p>Let’s now dive into the scenarios.</p><p><strong><em>Scenario 1 : </em></strong><em>Tenant icmp reachability</em></p><p>This scenario assesses the icmp reachability of end hosts (e.g. successful ping from host1 to host2 and host3), in addition to MTU check.<br>Since, each CrewAI task needs a <em>description</em> and an <em>expected output</em> to define its purpose and desired result, I added those as below (after enhancements over iterations):</p><pre>Task(<br>            description=&quot;&quot;&quot;<br>            Prove full tenant (host-to-host) reachability.<br>            From host1, test connectivity to host2 and host3.<br>            Then prove the overlay supports frames up to 1500 bytes by testing MTU:<br>            • ping -s 1422 -c 3 host3   ← 1422 + 8(ICMP) + 20(IP) + 50(VXLAN) = 1500 → perfect fit<br>            • ping -s 1472 -c 3 host3   ← should FAIL (1472 + 8 + 20 + 50 = 1550 &gt; 1500)<br><br>            Produce a clean report with:<br>            • Reachability matrix (host1&lt;-&gt;host2, host1&lt;-&gt;host3)<br>            • MTU test result<br>            • Final verdict: &quot;Tenant segment healthy&quot; or &quot;Issue detected&quot;<br>            &quot;&quot;&quot;,<br>            expected_output=&quot;Tenant reachability and MTU validation report with pass/fail&quot;,<br>            agent=create_l2_tester()<br>                ),</pre><p>Upon running, it generates this report</p><pre>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025/network_triage$ cat L2_EVPN_REPORT.md <br>**Tenant Reachability and MTU Validation Report**<br><br>**Reachability Matrix:**<br>- host1 ↔ host2: **Reachable** (3 packets transmitted, 3 packets received, 0% packet loss)<br>- host1 ↔ host3: **Reachable** (3 packets transmitted, 3 packets received, 0% packet loss)<br><br>**MTU Test Results:**<br>- Ping with 1422 bytes to host3: **Passed** (3 packets transmitted, 3 packets received, 0% packet loss)<br>- Ping with 1472 bytes to host3: **Failed** (3 packets transmitted, 0 packets received, 100% packet loss)<br><br>**Final Verdict:** Tenant segment healthy(venv) </pre><p>Note that, for the Agent <em>backstory , </em>i used,</p><pre>        role=&quot;Tenant Connectivity Specialist&quot;,<br>        goal=&quot;Prove full L2/L3 reachability between all hosts&quot;,<br>        backstory=f&quot;&quot;&quot;<br>        You are a network engineer.<br>        The lab has 3 hosts: host1 ({LAB.host_ip_of(&#39;host1&#39;)}), <br>        host2 ({LAB.host_ip_of(&#39;host2&#39;)}), host3 ({LAB.host_ip_of(&#39;host3&#39;)}).<br>        The hosts are in the same L2 VNI (VLAN 10 / VNI 10010).<br>        &quot;&quot;&quot;</pre><p>An interesting observation here was, as soon as i removed this context from backstory,</p><pre><br>The lab has 3 hosts: host1 ({LAB.host_ip_of(‘host1’)}), <br> host2 ({LAB.host_ip_of(‘host2’)}), host3 ({LAB.host_ip_of(‘host3’)}).</pre><p>the agent still concluded Tenant segment healthy, but it ended up pinging the host Mgmt IPs (e.g host3 mgmt IP. 172.20.20.33), likely rendered from <em>/etc/hosts, </em>which was never the user intent in the first place.</p><pre>1480 bytes from 172.20.20.33: seq=1 ttl=64 time=0.535 ms<br>1480 bytes from 172.20.20.33: seq=2 ttl=64 time=1.150 ms<br> — — host3 ping statistics — -<br>3 packets transmitted, 3 packets received, 0% packet loss<br>round-trip min/avg/max = 0.380/0.688/1.150 ms<br># Agent: Tenant Connectivity Specialist<br>## Final Answer: <br>**Tenant Reachability and MTU Validation Report**<br>**Reachability Matrix:**<br>- host1 ↔ host2: **Reachable** (3 packets transmitted, 3 packets received, 0% packet loss)<br>- host1 ↔ host3: **Reachable** (3 packets transmitted, 3 packets received, 0% packet loss)<br>**MTU Test Results:**<br>- Ping with size 1422: **Success** (3 packets transmitted, 3 packets received, 0% packet loss)<br>- Ping with size 1472: **Success** (3 packets transmitted, 3 packets received, 0% packet loss)<br>**Final Verdict:** Tenant segment healthy</pre><p><strong><em>Scenario 2:</em></strong><em> </em>Assesses the VTEP reachability for the given topology.</p><pre>Task(<br>   description=”””<br>   Prove full bidirectional VTEP reachability across the underlay.<br>   From each leaf, ping every other leaf’s Loopback0 (VTEP IP), <br>   sourcing from your own Loopback0 with a repeat count of 2.<br>   Test all 6 directions (3x2).<br>   Produce a clean VTEP reachability matrix with packet loss %.<br>   Final verdict must be: “All VTEPs fully reachable” or “VTEP connectivity issue detected”.<br>   “””,<br>   expected_output=”VTEP reachability matrix with pass/fail and final verdict”,<br>   agent=create_vtep_tester()<br> )</pre><p>Agent <em>backstory,</em></p><pre> role=”VTEP Reachability Specialist”,<br> goal=”Prove full IP reachability between all VXLAN Tunnel Endpoints (VTEPs)”,<br> backstory=f”””<br> You are a VXLAN underlay expert.<br> The VTEPs are the Loopback0 interfaces on the leaf switches:<br> {vtep_info}<br> These IPs are used as VXLAN tunnel sources and destinations.<br> Full bidirectional reachability between all VTEPs is required for VXLAN to function.<br> “””</pre><p>Sample run result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXYILTF-Rx00FiQFQxNhXA.png" /></figure><pre>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025/network_triage$ cat L2_EVPN_REPORT.md <br>```<br>VTEP Reachability Matrix:<br>| Source | Destination | Packet Loss (%) |<br>| - - - - -| - - - - - - -| - - - - - - - - - |<br>| leaf1 | leaf2 | 0% |<br>| leaf1 | leaf3 | 0% |<br>| leaf2 | leaf1 | 0% |<br>| leaf2 | leaf3 | 0% |<br>| leaf3 | leaf1 | 0% |<br>| leaf3 | leaf2 | 0% |<br>Final Verdict: All VTEPs fully reachable.<br>(venv) clab@MININT-NN6TBLM:~/TiP/Nov23_2025/network_triage$</pre><p><strong><em>Scenario 3</em></strong><em>: BGP EVPN Control Plane Check<br></em>The BGP expert runs on all three leaves to assess the evpn control plane health</p><pre>Task(<br>          description=&quot;&quot;&quot;<br>          Validate BGP EVPN control plane on all three leaves.<br>          On all 3 leaves: execute commands to validate bgp evpn summary ; bgp evpn route-type mac-ip and imet<br><br>          In a healthy 3-leaf fabric, you must see:<br>          • 2 BGP EVPN sessions Established<br>          • Exactly 4 Type-3 IMET lines ( 2 remote × 2 ECMP), excluding locally originated<br>          • Excluding locally originated route, Exactly 4 Type-2 MAC-IP lines<br><br>          Produce a per-leaf table and final verdict:<br>          &#39;BGP EVPN control plane healthy&#39; if all leaves match above<br>          Otherwise: clearly state which leaf and which metric is wrong<br>          &quot;&quot;&quot;,<br>          expected_output=&quot;Clear BGP EVPN validation report with correct expected counts&quot;,<br>          agent=create_bgp_expert()</pre><p>Agent <em>backstory,</em></p><pre> backstory=&quot;&quot;&quot;You are a senior Arista cEOS engineer specializing in EVPN/VXLAN.<br>You know exactly what a healthy 3-leaf symmetric EVPN fabric looks like on cEOS 4.34.1F:<br><br>- All BGP EVPN sessions must be Established<br>- Each leaf must receive 2 Type-2 (MAC-IP) routes per remote host (one via each spine)<br>- Each leaf must receive 2 Type-3 (IMET) routes per remote leaf (one via each spine)<br>- Route-type 2 (MAC-IP) and route-type 3 (IMET) must be present and correct<br>- RD/RT values must match across the fabric<br>You never misdiagnose a healthy symmetric fabric.&quot;&quot;&quot;</pre><p>Sample run result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tfmkT4ifm0axAaPjrtazIQ.png" /></figure><p>Verdict: BGP EVPN control plane is healthy</p><pre># Agent: BGP EVPN Control Plane Expert<br>## Final Answer: <br>BGP EVPN control plane healthy</pre><p><strong><em>Scenario 4</em></strong><em>: VXLAN Data Plane Validation</em></p><p>The VXLAN agent assesses the data plane in context of above topology:</p><pre>Task(                <br>                description=&quot;&quot;&quot;<br>                    You are the VXLAN Overlay Expert.<br><br>                    Your job is to prove the VXLAN data plane works perfectly across the fabric.<br><br>                    Step by step:<br>                    1. On every leaf, run commands to discover:<br>                    • Which VNI(s) are configured<br>                    • Which VLAN each VNI maps to<br>                    • The current state (up/down)<br><br>                    2. For each discovered VNI/VLAN pair, run commands to verify MAC learning:<br>                    • mac address-table<br>                    • vxlan address-table<br>                    • confirm tunnel is up<br><br>                    3. Verify the correct pattern:<br>                    • Every leaf sees its own host MAC on a physical Ethernet interface<br>                    • Every leaf sees the other two hosts&#39; MACs via vxlan interface (remote VTEP)<br>                    • No missing remote MACs<br>                    • No MACs learned on wrong interface<br><br>                    Produce a clean per-leaf report showing:<br>                    • VNI → VLAN mapping<br>                    • Local MAC count &amp; interface<br>                    • Remote MAC count &amp; VTEP IPs<br>                    • Final verdict: &quot;VXLAN data plane healthy&quot; or exact problem<br><br>                    Never assume VNI 10010 or VLAN 100 — discover them from real output.<br>                    &quot;&quot;&quot;,<br>                expected_output=&quot;Dynamic VXLAN data plane validation report with discovered VNI/VLAN and MAC learning proof&quot;,<br>                agent=create_vxlan_expert()<br>            )</pre><p>Agent <em>backstory</em></p><pre>backstory=f&quot;&quot;&quot;<br>        You are a VXLAN data-plane specialist.<br><br>        This fabric has:<br>        • {leaf_count} leaf switches: {&#39;, &#39;.join(LAB.leaves)}<br>        • {host_count} hosts: {&#39;, &#39;.join(LAB.hosts)}<br>        • Each leaf has exactly one directly connected host<br>        • All hosts belong to the same L2 domain (single VNI)<br><br>        You must discover everything yourself — no assumptions.<br><br>        Your validation rules:<br>        • Each leaf must discover exactly 1 active L2 VNI via &#39;show vxlan vni&#39;<br>        • Each leaf must learn:<br>            → 1 local MAC  → on a physical Ethernet interface (its directly connected host)<br>            → {host_count - 1} remote MACs → via Vxlan interface (from the other leaves)<br>        • Vxlan interface must be up/up<br>        • vxlan address table must show {host_count - 1} remote VTEPs learned<br><br>        Your process:<br>        1. On every leaf → discover VNI → VLAN mapping<br>        2. For each discovered VLAN, check MAC learning<br>        3. Prove every leaf sees 1 local MAC on directly connected physical interface and 2 remote MACs (on Vxlan interface)<br>        4. Confirm Vxlan interface is up/up and shows remote VTEPs<br>        Never hardcode anything.<br>        &quot;&quot;&quot;</pre><p>Sample result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfBrkwALuvb0fa_DseVHjg.png" /></figure><p>As seen above, while the verdict i itself looks correct, but the Leaf2 does <strong>not </strong>actually learn highlighted mac address locally.</p><p>Actual output from Leaf2 CLI,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4aQcoJQyJWiXewO1gBCR3g.png" /></figure><p><em>Scenario 5: Final Verdict</em></p><p>The analyst receives all evidence and concludes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yPqga3pMo7XE6bwI1iYfmA.png" /></figure><p>To begin with, the network was already healthy, and using these agents, we merely assessed the observed network state with the desired network state. As i learn and iterate over , i plan to introduce failure scenarios (likely in my next write up), and run triage through these agents again to assess if (at least, in context of this topology), can it be a truly autonomous/self healing network.</p><p><em>Code snippets</em></p><pre>network_triage/<br>├── config/<br>│   └── lab.py              <br>├── tools/<br>│   └── containerlab.py      <br>├── agents/<br>│   ├── __init__.py<br>│   ├── l2_tester.py<br>│   ├── bgp_expert.py<br>│   ├── vxlan_expert.py<br>│   └── analyst.py<br>├── tasks/<br>│   └── triage.py<br>├── main.py<br>└── crew.py </pre><p><em>lab.py</em></p><pre>from dataclasses import dataclass<br>from typing import List, Dict<br><br>@dataclass<br>class Lab:<br>    prefix: str = &quot;clab-vxlan-ebgp-multiAS-&quot;<br><br>    # Node lists<br>    hosts: List[str] = None<br>    leaves: List[str] = None<br>    spines: List[str] = None<br><br>    # IP mappings<br>    loopbacks: Dict[str, str] = None    <br>    hostIps: Dict[str, str] = None<br><br>    def __post_init__(self):<br>        self.hosts = self.hosts or [&quot;host1&quot;, &quot;host2&quot;, &quot;host3&quot;]<br>        self.leaves = self.leaves or [&quot;leaf1&quot;, &quot;leaf2&quot;, &quot;leaf3&quot;]<br>        self.spines = self.spines or [&quot;spine1&quot;, &quot;spine2&quot;]<br><br>        self.loopbacks = self.loopbacks or {<br>            &quot;leaf1&quot;:  &quot;3.3.3.3&quot;,<br>            &quot;leaf2&quot;:  &quot;4.4.4.4&quot;,<br>            &quot;leaf3&quot;:  &quot;5.5.5.5&quot;,<br>            &quot;spine1&quot;: &quot;11.11.11.11&quot;,<br>            &quot;spine2&quot;: &quot;22.22.22.22&quot;,<br>        }<br><br>        self.hostIps = self.hostIps or {<br>            &quot;host1&quot;:  &quot;172.16.1.1&quot;,<br>            &quot;host2&quot;:  &quot;172.16.1.2&quot;,<br>            &quot;host3&quot;:  &quot;172.16.1.3&quot;,<br>        }<br><br>    def all_nodes(self) -&gt; List[str]:<br>        return self.hosts + self.leaves + self.spines<br><br>    def container(self, node: str) -&gt; str:<br>        return f&quot;{self.prefix}{node}&quot;<br><br>    def loopback_of(self, node: str) -&gt; str:<br>        &quot;&quot;&quot;Helper: returns loopback IP of a given router&quot;&quot;&quot;<br>        return self.loopbacks.get(node, &quot;UNKNOWN&quot;)<br>    <br>    def host_ip_of(self, node: str) -&gt; str:<br>        &quot;&quot;&quot;Helper: returns host IP of a given node&quot;&quot;&quot;<br>        return self.hostIps.get(node, &quot;UNKNOWN&quot;)<br><br>LAB = Lab()</pre><p><em>containerlab.py</em></p><pre>from crewai_tools import tool<br>import subprocess<br>from config.lab import LAB<br><br>@tool(&quot;Run command inside any node&quot;)<br>def run_command_inside_any_node(node: str, command: str) -&gt; str:<br>    &quot;&quot;&quot;Run a command inside a Containerlab node. Automatically enters privileged mode on cEOS nodes.&quot;&quot;&quot;<br>    <br>    if node not in LAB.all_nodes():<br>        return f&quot;ERROR: Unknown node &#39;{node}&#39;. Valid: {&#39;, &#39;.join(LAB.all_nodes())}&quot;<br><br>    container = LAB.container(node)<br><br>    if node.startswith((&quot;leaf&quot;, &quot;spine&quot;)):<br>        full_command = f&quot;enable\n{command}&quot;<br>        exec_cmd = [&quot;sudo&quot;, &quot;docker&quot;, &quot;exec&quot;, container, &quot;Cli&quot;, &quot;-c&quot;, full_command]<br>    else:<br>        # Hosts (Alpine): normal shell<br>        exec_cmd = [&quot;sudo&quot;, &quot;docker&quot;, &quot;exec&quot;, container, &quot;sh&quot;, &quot;-c&quot;, command]<br><br>    print(f&quot;{container} → {command}&quot;)<br>    result = subprocess.run(exec_cmd, capture_output=True, text=True, timeout=60)<br>    <br>    output = f&quot;RC: {result.returncode}\n&quot;<br>    if result.stdout.strip():<br>        output += f&quot;STDOUT:\n{result.stdout.strip()}\n&quot;<br>    if result.stderr.strip():<br>        output += f&quot;STDERR:\n{result.stderr.strip()}&quot;<br>    <br>    return output.strip() or &quot;No output&quot;<br><br>run_tool = run_command_inside_any_node</pre><p><em>l2_tester.py</em></p><pre>from crewai import Agent<br>from langchain_openai import ChatOpenAI<br>from tools.containerlab import run_tool<br>from config.lab import LAB<br>import json<br><br>llm = ChatOpenAI(model=&quot;gpt-4o-mini&quot;, temperature=0.0)<br><br>def create_l2_tester():<br>    host_ips = json.dumps(LAB.hostIps, indent=2)<br>    print(f&quot;L2 Tester knows host IPs:\n{host_ips}&quot;)<br><br>    return Agent(<br>        role=&quot;Tenant Connectivity Specialist&quot;,<br>        goal=&quot;Prove full L2/L3 reachability between all hosts&quot;,<br>        backstory=f&quot;&quot;&quot;<br>        You are a network engineer.<br>        The lab has 3 hosts: host1 ({LAB.host_ip_of(&#39;host1&#39;)}), <br>        host2 ({LAB.host_ip_of(&#39;host2&#39;)}), host3 ({LAB.host_ip_of(&#39;host3&#39;)}).<br>        The hosts are in the same L2 VNI (VLAN 10 / VNI 10010).<br>        &quot;&quot;&quot;,<br>        tools=[run_tool],<br>        llm=llm,<br>        verbose=True,<br>        memory=True,<br>        allow_delegation=False<br>    )</pre><p><em>bgp_expert.py</em></p><pre>from crewai import Agent<br>from tools.containerlab import run_tool<br>from agents import llm<br><br>def create_bgp_expert():<br>    return Agent(<br>        role=&quot;BGP EVPN Control Plane Expert&quot;,<br>        goal=&quot;Validate BGP EVPN sessions and route advertisement&quot;,<br>        backstory=&quot;&quot;&quot;You are a senior Arista cEOS engineer specializing in EVPN/VXLAN.<br>You know exactly what a healthy 3-leaf symmetric EVPN fabric looks like on cEOS 4.34.1F:<br><br>- All BGP EVPN sessions must be Established<br>- Each leaf must receive 2 Type-2 (MAC-IP) routes per remote host (one via each spine)<br>- Each leaf must receive 2 Type-3 (IMET) routes per remote leaf (one via each spine)<br>- Route-type 2 (MAC-IP) and route-type 3 (IMET) must be present and correct<br>- RD/RT values must match across the fabric<br>You never misdiagnose a healthy symmetric fabric.&quot;&quot;&quot;,<br>        tools=[run_tool],<br>        llm=llm,<br>        verbose=True,<br>        allow_delegation=False,<br>        memory=True<br>    )</pre><p><em>vtep_tester.py</em></p><pre>from crewai import Agent<br>from langchain_openai import ChatOpenAI<br>from tools.containerlab import run_tool<br>from config.lab import LAB<br>import json<br><br>llm = ChatOpenAI(model=&quot;gpt-4o-mini&quot;, temperature=0.0)<br><br>def create_vtep_tester():<br>    # Only leaf loopbacks are VTEPs<br>    vtep_ips = {node: ip for node, ip in LAB.loopbacks.items() if node.startswith(&quot;leaf&quot;)}<br>    vtep_info = json.dumps(vtep_ips, indent=2)<br>    print(f&quot;VTEP Tester knows VTEP IPs:\n{vtep_info}&quot;)<br><br>    return Agent(<br>        role=&quot;VTEP Reachability Specialist&quot;,<br>        goal=&quot;Prove full IP reachability between all VXLAN Tunnel Endpoints (VTEPs)&quot;,<br>        backstory=f&quot;&quot;&quot;<br>        You are a VXLAN underlay expert.<br>        The VTEPs are the Loopback0 interfaces on the leaf switches:<br>        {vtep_info}<br>        These IPs are used as VXLAN tunnel sources and destinations.<br>        Full bidirectional reachability between all VTEPs is required for VXLAN to function.<br>        &quot;&quot;&quot;,<br>        tools=[run_tool],<br>        llm=llm,<br>        verbose=True,<br>        memory=True,<br>        allow_delegation=False<br>    )</pre><p><em>vxlan_expert.py</em></p><pre>from crewai import Agent<br>from tools.containerlab import run_tool<br>from config.lab import LAB<br>from agents import llm<br><br>def create_vxlan_expert():<br>    leaf_count = len(LAB.leaves)<br>    host_count = len(LAB.hosts)<br>    return Agent(<br>        role=&quot;VXLAN Overlay Expert&quot;,<br>        goal=&quot;Prove VXLAN data plane works end-to-end by discovering everything yourself&quot;,<br>        backstory=f&quot;&quot;&quot;<br>        You are a VXLAN data-plane specialist.<br><br>        This fabric has:<br>        • {leaf_count} leaf switches: {&#39;, &#39;.join(LAB.leaves)}<br>        • {host_count} hosts: {&#39;, &#39;.join(LAB.hosts)}<br>        • Each leaf has exactly one directly connected host<br>        • All hosts belong to the same L2 domain (single VNI)<br><br>        You must discover everything yourself — no assumptions.<br><br>        Your validation rules:<br>        • Each leaf must discover exactly 1 active L2 VNI via &#39;show vxlan vni&#39;<br>        • Each leaf must learn:<br>            → 1 local MAC  → on a physical Ethernet interface (its directly connected host)<br>            → {host_count - 1} remote MACs → via Vxlan interface (from the other leaves)<br>        • Vxlan interface must be up/up<br>        • vxlan address table must show {host_count - 1} remote VTEPs learned<br><br>        Your process:<br>        1. On every leaf → discover VNI → VLAN mapping<br>        2. For each discovered VLAN, check MAC learning<br>        3. Prove every leaf sees 1 local MAC on directly connected physical interface and 2 remote MACs (on Vxlan interface)<br>        4. Confirm Vxlan interface is up/up and shows remote VTEPs<br>        Never hardcode anything.<br>        &quot;&quot;&quot;,<br>        tools=[run_tool],<br>        llm=llm,<br>        verbose=True<br>    )</pre><p><em>analyst.py</em></p><pre>from crewai import Agent<br>from agents import llm<br><br>def create_analyst():<br>    return Agent(<br>        role=&quot;Root Cause Analyst&quot;,<br>        goal=&quot;Give final verdict&quot;,<br>        backstory=&quot;You precisely understand a healthy symmetric EVPN fabric.&quot;,<br>        llm=llm,<br>        verbose=True<br>    )</pre><p><em>triage.py</em></p><pre>from crewai import Task<br>from agents.l2_tester import create_l2_tester<br>from agents.vtep_tester import create_vtep_tester<br>from agents.bgp_expert import create_bgp_expert<br>from agents.vxlan_expert import create_vxlan_expert<br>from agents.analyst import create_analyst<br><br>&#39;&#39;&#39;<br>def get_tasks():<br>    return [        <br>            Task(                <br>                description=&quot;&quot;&quot;<br>                    You are the VXLAN Overlay Expert.<br><br>                    Your job is to prove the VXLAN data plane works perfectly across the fabric.<br><br>                    Step by step:<br>                    1. On every leaf, run commands to discover:<br>                    • Which VNI(s) are configured<br>                    • Which VLAN each VNI maps to<br>                    • The current state (up/down)<br><br>                    2. For each discovered VNI/VLAN pair, run commands to verify MAC learning:<br>                    • mac address-table<br>                    • vxlan address-table<br>                    • confirm tunnel is up<br><br>                    3. Verify the correct pattern:<br>                    • Every leaf sees its own host MAC on a physical Ethernet interface<br>                    • Every leaf sees the other two hosts&#39; MACs via vxlan interface (remote VTEP)<br>                    • No missing remote MACs<br>                    • No MACs learned on wrong interface<br><br>                    Produce a clean per-leaf report showing:<br>                    • VNI → VLAN mapping<br>                    • Local MAC count &amp; interface<br>                    • Remote MAC count &amp; VTEP IPs<br>                    • Final verdict: &quot;VXLAN data plane healthy&quot; or exact problem<br><br>                    Never assume VNI 10010 or VLAN 100 — discover them from real output.<br>                    &quot;&quot;&quot;,<br>                expected_output=&quot;Dynamic VXLAN data plane validation report with discovered VNI/VLAN and MAC learning proof&quot;,<br>                agent=create_vxlan_expert()<br>            )<br>        ]<br><br>&#39;&#39;&#39;<br><br><br>def get_tasks():<br>    return [<br>        Task(<br>            description=<br>            &quot;&quot;&quot;<br>            Prove full tenant (host-to-host) reachability.<br><br>            From host1, test connectivity to host2 and host3.<br><br>            Then prove the overlay supports frames up to 1500 bytes by testing MTU:<br>            • ping -s 1422 -c 3 host3   ← 1422 + 8(ICMP) + 20(IP) + 50(VXLAN) = 1500 → perfect fit<br>            • ping -s 1472 -c 3 host3   ← should FAIL (1472 + 8 + 20 + 50 = 1550 &gt; 1500)<br><br>            Produce a clean report with:<br>            • Reachability matrix (host1 ↔ host2, host1 ↔ host3)<br>            • MTU test result<br>            • Final verdict: &quot;Tenant segment healthy&quot; or &quot;Issue detected&quot;<br>    &quot;&quot;&quot;,<br>    expected_output=&quot;Tenant reachability and MTU validation report with clear pass/fail&quot;,<br>    agent=create_l2_tester()<br>        ),<br>        Task(<br>            description=&quot;&quot;&quot;<br>            Prove full bidirectional VTEP reachability across the underlay.<br><br>            From each leaf, ping every other leaf&#39;s Loopback0 (VTEP IP), <br>            sourcing from your own Loopback0 with a repeat count of 2.<br>            Test all 6 directions (3x2).<br><br>            Produce a clean VTEP reachability matrix with packet loss %.<br>            Final verdict must be: &quot;All VTEPs fully reachable&quot; or &quot;VTEP connectivity issue detected&quot;.<br>            &quot;&quot;&quot;,<br>            expected_output=&quot;VTEP reachability matrix with pass/fail and final verdict&quot;,<br>            agent=create_vtep_tester()<br>        ),<br>        Task(<br>                description=&quot;&quot;&quot;<br>                Validate BGP EVPN control plane on all three leaves.<br>                On all 3 leaves: execute commands to validate bgp evpn summary ; bgp evpn route-type mac-ip and imet<br><br>                In a healthy 3-leaf fabric, you must see:<br>                • 2 BGP EVPN sessions Established<br>                • Exactly 4 Type-3 IMET lines ( 2 remote × 2 ECMP), excluding locally originated<br>                • Excluding locally originated route, Exactly 4 Type-2 MAC-IP lines<br><br>                Produce a per-leaf table and final verdict:<br>                &#39;BGP EVPN control plane healthy&#39; if all leaves match above<br>                Otherwise: clearly state which leaf and which metric is wrong<br>                &quot;&quot;&quot;,<br>                expected_output=&quot;Clear BGP EVPN validation report with correct expected counts&quot;,<br>                agent=create_bgp_expert()<br>            ),<br>        Task(                <br>                description=&quot;&quot;&quot;<br>                    You are the VXLAN Overlay Expert.<br><br>                    Your job is to prove the VXLAN data plane works perfectly across the fabric.<br><br>                    Step by step:<br>                    1. On every leaf, run commands to discover:<br>                    • Which VNI(s) are configured<br>                    • Which VLAN each VNI maps to<br>                    • The current state (up/down)<br><br>                    2. For each discovered VNI/VLAN pair, run commands to verify MAC learning:<br>                    • mac address-table<br>                    • vxlan address-table<br>                    • confirm tunnel is up<br><br>                    3. Verify the correct pattern:<br>                    • Every leaf sees its own host MAC on a physical Ethernet interface<br>                    • Every leaf sees the other two hosts&#39; MACs via vxlan interface (remote VTEP)<br>                    • No missing remote MACs<br>                    • No MACs learned on wrong interface<br><br>                    Produce a clean per-leaf report showing:<br>                    • VNI → VLAN mapping<br>                    • Local MAC count &amp; interface<br>                    • Remote MAC count &amp; VTEP IPs<br>                    • Final verdict: &quot;VXLAN data plane healthy&quot; or exact problem<br><br>                    Never assume VNI 10010 or VLAN 100 — discover them from real output.<br>                    &quot;&quot;&quot;,<br>                expected_output=&quot;Dynamic VXLAN data plane validation report with discovered VNI/VLAN and MAC learning proof&quot;,<br>                agent=create_vxlan_expert()<br>            )       <br>        ,<br>        Task(<br>            description=&quot;Write final Markdown report. If everything is correct → say &#39;Fabric is 100% healthy&#39;. Only give one-line docker fix if broken.&quot;,<br>            expected_output=&quot;Final verdict&quot;,<br>            agent=create_analyst()<br>        )<br>    ]</pre><p><em>crew.py</em></p><pre>from crewai import Crew, Process<br>from tasks.triage import get_tasks<br>from agents.l2_tester import create_l2_tester<br>from agents.bgp_expert import create_bgp_expert<br>from agents.vxlan_expert import create_vxlan_expert<br>from agents.analyst import create_analyst<br>from agents.vtep_tester import create_vtep_tester<br><br>def create_crew():<br>    return Crew(<br>        agents=[create_l2_tester(), create_vtep_tester(), create_bgp_expert(), create_vxlan_expert(), create_analyst()],<br>        tasks=get_tasks(),<br>        process=Process.sequential,<br>        verbose=True<br>    )</pre><p><em>main.py</em></p><pre>from crew import create_crew<br><br>if __name__ == &quot;__main__&quot;:<br>    print(&quot;STARTING CLEAN BASELINE CHECK&quot;)<br>    crew = create_crew()<br>    result = crew.kickoff()<br>    with open(&quot;L2_EVPN_REPORT.md&quot;, &quot;w&quot;) as f:<br>        f.write(result.raw if hasattr(result, &quot;raw&quot;) else str(result))<br>    print(&quot;DONE → L2_EVPN_REPORT.md&quot;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=202902d0aa03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using GenAI for basic network triaging scenario]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/using-genai-for-basic-network-triaging-scenario-8deb3d64daed?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/8deb3d64daed</guid>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 12:56:05 GMT</pubDate>
            <atom:updated>2025-08-10T12:56:05.353Z</atom:updated>
            <content:encoded><![CDATA[<p>To begin with, we set up the topology such that, end hosts shown below are able to communicate (icmp) with each other(underlay — eBGP, overlay — vxlan).</p><p>For the underlay network, physical P2P IP addresses are used for eBGP neighbor adjacency. Once <em>Established, </em>the loopback addresses are advertised , which can then be used for overlay network for neighbor adjacency.</p><p><em>Topology</em></p><p>2 Spines, 3 Leaf Routers, 1 host connected to each Leaf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*97PZpGcuhSAZPRRoBQliKQ.png" /></figure><pre>clab@MININT-NN6TBLM:~/TiP/AUG8_2025$ cat topology.yml <br>name: vxlan-ebgp-multiAS<br><br>mgmt:<br>  network: clab-mgmt<br>  ipv4-subnet: 172.20.20.0/24<br><br>topology:<br>  nodes:<br>    # Spine Switches (AS 12)<br>    spine1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.11<br>      startup-config: configs/spine1.cfg<br>      ports:<br>        - &quot;2001:22&quot;<br>        - &quot;8001:80&quot;<br>        - &quot;44301:443&quot;<br>      <br>    spine2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.12<br>      startup-config: configs/spine2.cfg<br>      ports:<br>        - &quot;2002:22&quot;<br>        - &quot;8002:80&quot;<br>        - &quot;44302:443&quot;<br><br>    # Leaf Switches (AS 2, 3, 4)<br>    leaf1:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.21<br>      startup-config: configs/leaf1.cfg<br>      ports:<br>        - &quot;2021:22&quot;<br>        - &quot;8021:80&quot;<br>        - &quot;44321:443&quot;<br>      <br>    leaf2:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.22<br>      startup-config: configs/leaf2.cfg<br>      ports:<br>        - &quot;2022:22&quot;<br>        - &quot;8022:80&quot;<br>        - &quot;44322:443&quot;<br>      <br>    leaf3:<br>      kind: ceos<br>      image: ceos:4.34.1F<br>      mgmt-ipv4: 172.20.20.23<br>      startup-config: configs/leaf3.cfg<br>      ports:<br>        - &quot;2023:22&quot;<br>        - &quot;8023:80&quot;<br>        - &quot;44323:443&quot;<br><br>    # Host containers<br>    host1:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.31<br>      exec:<br>        - ip addr add 172.16.1.1/24 dev eth1<br>      <br>    host2:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.32<br>      exec:<br>        - ip addr add 172.16.1.2/24 dev eth1<br>      <br>    host3:<br>      kind: linux<br>      image: alpine:latest<br>      mgmt-ipv4: 172.20.20.33<br>      exec:<br>        - ip addr add 172.16.1.3/24 dev eth1<br><br>  links:<br>    # Spine1 to Leaf connections<br>    - endpoints: [&quot;spine1:eth1&quot;, &quot;leaf1:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth2&quot;, &quot;leaf2:eth1&quot;]<br>    - endpoints: [&quot;spine1:eth3&quot;, &quot;leaf3:eth1&quot;]<br>    <br>    # Spine2 to Leaf connections<br>    - endpoints: [&quot;spine2:eth1&quot;, &quot;leaf1:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth2&quot;, &quot;leaf2:eth2&quot;]<br>    - endpoints: [&quot;spine2:eth3&quot;, &quot;leaf3:eth2&quot;]<br>    <br>    # Host connections<br>    - endpoints: [&quot;leaf1:eth3&quot;, &quot;host1:eth1&quot;]<br>    - endpoints: [&quot;leaf2:eth3&quot;, &quot;host2:eth1&quot;]<br>    - endpoints: [&quot;leaf3:eth3&quot;, &quot;host3:eth1&quot;]<br><br>clab@MININT-NN6TBLM:~/TiP/AUG8_2025$ </pre><p><em>Interfaces with corresponding IPs</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YomUmfHdi0HsSvEaesJ7bg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfSOw3x6-MuazYSIBU9aTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uctaXle6RGybb9MJ_MGepQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uTQja343TvyBlSPYP9GTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpAZBh9a5x3fn5Q0ivu_5g.png" /></figure><p><em>eBGP P2P peerings between Leaf and Spine Devices</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyzXkw7uJLTzAZ3RhEHsqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynYZUDvjEIy2VTZHZTD2ZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCvEcw5KIwsf6pWXb-r0xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDO6lrSOS_DjDez4c9VlZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oh2ZP8oUhlDHzkSUgjc0g.png" /></figure><p><em>Leaf1 loopback to Spine1/Spine2 loopback reachability</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*cxNBBUGRbtKDDRj_N-qiEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2KNqIFyuVNIfXM_dRomEQ.png" /></figure><p>Similarly, Leaf2/Leaf3 (using source interface loopback0) can reach the loopbacks of Spine1/Spine2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*ACL5emHKHF80yzNkH79nBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmusHPATN2-pUjvgCJ9SHw.png" /></figure><p><em>Leaf1 loopback to Leaf2/Leaf3 loopback reachability</em></p><p>ECMP is enabled (<em>maximum path</em> configured) on the leaf routers, hence, 2 paths for the destination prefix as seen below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*8fxt4OuOSMImZJFIILC-4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2eWx3jpysIuOmEzhOJMQA.png" /></figure><p>At this point, we conclude, underlay network is ready.</p><p><strong><em>Building the overlay network</em></strong></p><ul><li>On Leaf routers, establish eBGP neighborship sourced from loopback of Leaf towards the loopback of Spine Routers.</li><li>Similarly, update the Spine routers with eBGP neighborship sourced from loopback towards the loopback of Leaf Routers.</li><li>All routers support EVPN address family</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZAX89Qn3fHYmqdfsGBcSg.png" /></figure><p>On Host1,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N19vFoWB4EYNyHuDJgqJjQ.png" /></figure><p>On Leaf1,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHIUmAIcUO23ENaI-cDgCA.png" /></figure><p>Similarly, on Leaf2, Leaf3 and corresponding Host2 , Host3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ns4uFTlPbdjiqxisLqpbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSbuZj76es-k66U9dAGscg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjzNjVPMNRQll6gvAmXQEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWYPWH2D0om_Mdp2Uarr7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VaN10BYLfm1x2uyYuQHT4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kMFcxmlgYKHTIPtiS2dm0Q.png" /></figure><p>Host IP addresses are as follows:</p><pre>/ # hostname<br>host1<br>/ # <br>/ # ifconfig | grep 172.16<br> inet addr:172.16.1.1 Bcast:0.0.0.0 Mask:255.255.255.0<br>/ #</pre><pre>/ # hostname<br>host2<br>/ # <br>/ # ifconfig | grep 172.16<br> inet addr:172.16.1.2 Bcast:0.0.0.0 Mask:255.255.255.0<br>/ #</pre><pre>/ # hostname<br>host3<br>/ # <br>/ # ifconfig | grep 172.16<br> inet addr:172.16.1.3 Bcast:0.0.0.0 Mask:255.255.255.0<br>/ #</pre><p>Now validating, if BGP EVPN peerings are <em>Established</em></p><pre>leaf1#show bgp evpn summary<br>BGP summary information for VRF default<br>Router identifier 3.3.3.3, local AS number 2<br>Neighbor Status Codes: m — Under maintenance<br> Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc PfxAdv<br> 11.11.11.11 4 12 889 907 0 0 12:19:52 Estab 2 2 1<br> 22.22.22.22 4 12 891 897 0 0 12:19:52 Estab 2 2 3<br>leaf1#</pre><pre>leaf2#show bgp evpn summary <br>BGP summary information for VRF default<br>Router identifier 4.4.4.4, local AS number 3<br>Neighbor Status Codes: m — Under maintenance<br> Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc PfxAdv<br> 11.11.11.11 4 12 1261 1270 0 0 12:20:27 Estab 2 2 3<br> 22.22.22.22 4 12 1233 1240 0 0 16:46:11 Estab 2 2 1<br>leaf2#</pre><pre>leaf3#show bgp evpn summary <br>BGP summary information for VRF default<br>Router identifier 5.5.5.5, local AS number 4<br>Neighbor Status Codes: m — Under maintenance<br> Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc PfxAdv<br> 11.11.11.11 4 12 907 909 0 0 12:21:47 Estab 2 2 3<br> 22.22.22.22 4 12 913 891 0 0 12:21:50 Estab 2 2 1<br>leaf3#</pre><pre>spine1#show bgp evpn summary <br>BGP summary information for VRF default<br>Router identifier 11.11.11.11, local AS number 12<br>Neighbor Status Codes: m — Under maintenance<br> Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc PfxAdv<br> 3.3.3.3 4 2 911 893 0 0 12:22:54 Estab 1 1 2<br> 4.4.4.4 4 3 911 897 0 0 12:22:58 Estab 1 1 2<br> 5.5.5.5 4 4 911 909 0 0 12:22:59 Estab 1 1 2<br>spine1#</pre><pre>spine2#show bgp evpn summary<br>BGP summary information for VRF default<br>Router identifier 22.22.22.22, local AS number 12<br>Neighbor Status Codes: m — Under maintenance<br> Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc PfxAdv<br> 3.3.3.3 4 2 1287 1274 0 0 12:23:26 Estab 1 1 2<br> 4.4.4.4 4 3 1271 1263 0 0 16:49:13 Estab 1 1 2<br> 5.5.5.5 4 4 1248 1280 0 0 12:23:34 Estab 1 1 2<br>spine2#</pre><p>Leaf1 learns the evpn route for host3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KGAM4_eoyT-f8Hls2DlEiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0zihIulEJfzTjsLG1z2Vw.png" /></figure><p>Finally, successful ping from host1 towards host3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qnywc5hFM-cHsyaPoOcgxQ.png" /></figure><p>As part of this, some of the questions that i tried clarifying with some of the GenAI tools.</p><ol><li>Why is the Type shown as <em>Dynamic </em>instead of <em>EVPN </em>?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZC0KsVn32sW5lF7IBskvNA.png" /></figure><p>Grok’s response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzL7wptiwQ1BRcn04Z8SgQ.png" /></figure><p>However, in cEOS lab, despite me configuring, <em>send-community</em> under eVPN address-family, it is not rendered in CLI config.</p><p>Further, when i asked the same question to GPT5, response is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhCcIt_YfbkUjvP3KNaBaw.png" /></figure><p>Upon, conveying the same to Grok, it insisted, that GPT5 is incorrect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejnxzYvDVi-PLGPT8ddobA.png" /></figure><p>Grok’s response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LOLyP442_2hnjBs60sJ5qA.png" /></figure><p>Further, shared with Grok,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vueuxU2FPWMO93UK6q9I1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qJbuFop7TVrGv6AjebFsw.png" /></figure><p>When, i finally , ask it to “think harder”,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ilmKrEgoi0Bpc_KAFI8EbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*HTqrvKkxlkS0Jvs6gK5IIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*p2TLQs9I6lzeifvorn911g.png" /></figure><p>Did few other tests, example, set up the Host2 IP address to be in a different subnet, which, Grok was able to triage right away.</p><pre><br>/ # hostname<br>host2<br>/ # ifconfig | grep 172.16<br> inet addr:172.16.2.1 Bcast:0.0.0.0 Mask:255.255.255.0</pre><pre>/ # hostname<br>host1<br>/ # ping 172.16.2.1<br>PING 172.16.2.1 (172.16.2.1): 56 data bytes<br>^C<br> — — 172.16.2.1 ping statistics — -<br>3 packets transmitted, 0 packets received, 100% packet loss<br>/ # ^C</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUofFktVNphvgCpDUXbAQw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8deb3d64daed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TCP Fundamentals Analysis with Wireshark]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/tcp-fundamentals-analysis-with-wireshark-7c9526301170?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c9526301170</guid>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 16:41:00 GMT</pubDate>
            <atom:updated>2025-05-01T11:38:53.085Z</atom:updated>
            <content:encoded><![CDATA[<p>Notes shared below use <a href="https://www.linkedin.com/in/cgreer?original_referer=https%3A%2F%2Fwww.google.com%2F">Chris Geer</a>’s course i.e <a href="https://app.pluralsight.com/library/courses/foundational-tcp-analysis-wireshark/"><em>Foundational TCP Analysis with Wireshark</em></a><em> </em>as reference. All snapshots shown below are owned and developed by Chris Geer, and these are merely added here to capture notes. I am neither the author nor the contributor to any of the snapshots below.</p><p><strong>What is a TCP connection ? </strong><br>A TCP connection is identified by four tuples i.e an <em>IP address and a TCP port number. </em>At any given point of time a client and server may have multiple TCP connections which can be uniquely identified by four tuple.<br>E.g.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5Aq83xF-ohpJkBFoVLxlQ.png" /></figure><p><strong>TCP Connection States</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6h5JAusnlIA6pWe5gGlFw.png" /></figure><p><strong>TCP 3-way handshake</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJPKULHG1cMBC99EWvXUSw.png" /></figure><p>From a client perspective, using the timestamp diff between the SYN and the final ACK packet, we can fetch the initial RTT. This can likely help us root cause network latency scenarios.</p><p><strong>TCP Window size<br></strong>During the handshake, it advertises what the TCP receive buffer size is. This can vary/change up/down depending on scenario.</p><p><strong>TCP Window scale</strong></p><p>One of the fields in TCP options.<br>If we multiply this window size by window scale, that would give us the receive window, and the server can receive that much data on the wire before an ACK is sent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g48LYoeMZ2pFK-hNAV0Clw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEzEJDOTNtpLPyxdpYCywg.png" /></figure><p>Calculated Window size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4kfc8QPmLPOwBqBwyKrlQ.png" /></figure><p><strong>TCP Options</strong></p><p>During the handshake, <em>TCP Options</em> are also exchanged. <br>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtaiL06NLWNSr16q5-fAnA.png" /></figure><p><strong>TCP Maximum Segment Size</strong></p><p>It is an advertisement of how much data can be received in one single segment. Both client and server honor the MTU segment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkouRjrdrHLe--c1WV_XOQ.png" /></figure><p><strong>MTU vs MSS</strong></p><p>MTU concerns <em>network </em>, while MSS concerns <em>TCP.<br></em>IP header is 20 bytes, TCP header is 20 bytes<em><br></em>Standard Ethernet supports an MTU of 1500 bytes.<br>20 byte IP header + 20 byte TCP header, the 1460 byte that remains, is payload that can be transmitted in one frame. This is referred as TCP MSS.</p><p>So, there may be scenarios, such as below, where the network, may adjust MSS to accommodate the remaining bytes (E.g MTU set to 1400, so max TCP SYN MSS can be 1400–20–20 = 1360)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-m_zoXIYk5AOxKhUnHhN-Q.png" /></figure><p><strong>How many TCP connections are in the trace file?</strong></p><p>Open the pcap file in wireshark and navigate to<em> Statistics -&gt; Converstaions</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puXhatkNJ5M3IOhH2p_pQw.png" /></figure><p><strong>Filter for the one that has the most packets. What is the four-tuple of this connection? (IP addresses and TCP port numbers)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVM_rX572cRiTi4CN-j2gw.png" /></figure><p><strong>Measure the initial network roundtrip time between these two endpoints.<br></strong>To find the initial RTT, we need to focus on TCP 3-way handshake for this connection. Apply the filter as shown below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47IAh8zsUopTg3o1wHNLGw.png" /></figure><p>Then <em>Close </em>the above window, so you have a filter applied on the main window, as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xt-MIIRUCFcRNrEP9yPxTw.png" /></figure><p>We can then select packet 231, which is <em>SYN/ACK</em> packet, and it will show the iRTT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9JI87nfIXxkJs6sVvjEQiQ.png" /></figure><p><strong>What MSS is in use by the client? The server?<br></strong>Apply the below value as <em>Column, </em>so it will be directly visible w/o navigating each packet header.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*W15C13NhumqYOdtPmXeyAg.png" /></figure><p><strong>What TCP options will be allowed on the connection?<br></strong>From a <em>client </em>perspective, the<em> Options</em> are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aZddjLoTcIOm90F-W2Im4A.png" /></figure><p>From a server perspective, the <em>Options</em> are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqf7zUw5EaY3MySCB3qILw.png" /></figure><p>Note that that all these Options are exchanged in TCP handshake, and if we missed that in the capture, there is no way for us to identify the <em>Window scale</em>, as it is only advertised once.</p><p><strong>What Window scale is the client using? The server?<br></strong>Already captured above</p><p><strong>In this connection, what is the largest calculated window size on either the client or server side?<br></strong>Apply <em>Calculated Window Size</em> as one of the columns and sort by descending order.<br>So, this is the maximum amount of data that can be sent at once in either direction outstanding. So from a client perspective, server can send 173K of data at once before it receives an acknowledgement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmAc5RL-GQ__KN0UNVj2QA.png" /></figure><p><strong>What is the smallest advertised MSS value in the whole trace file?<br></strong>Add the <em>MSS value column</em> and sort by ascending order.<br>Since this concerns whole trace file, we will remove the filter used in previous questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwAnxnar9U4FuKYWWpbvpw.png" /></figure><p><strong>What is the fastest Initial network roundtrip time in the trace file? (Any TCP connection counts)<br></strong>Around 121 ms</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KjpDzwfE4_E83RdIX7nQQ.png" /></figure><p><strong>How many SYNs are there in this trace? (count SYN/ACK packets too)<br></strong>Applied the filter <em>tcp.flags.syn==1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xb8scKrHvRFUjqlvZITlBA.png" /></figure><p><strong>Initial Sequence Number</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXTGMGL2TfgKS3cUDgR9iw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IthTac1tQV9PRHe8k037vA.png" /></figure><p>Assume the data to be sent is 8760 bytes. This data is then broken into maximum segment size that receiver on the other end can receive. Assume, Server has MSS of 1460 i.e, 1460 bytes of data can be received in a single packet. So the client, breaks those into several smaller segments,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGVVh2dMmKmAUuSb-DJG4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8e7tcBkBMFTx0_gsAtXbWw.png" /></figure><p>Since TCP likes to be efficient, it is not going to send ACK for every single packet. Rather it can acknowledge multiple packets at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtFYsmNtYYRfCz7ZMKiSfw.png" /></figure><p>Now, the client can look at acknowledgement number to confirm that it has successfully received the first 2 packets (i.e upto 2920 bytes)</p><p><strong>Determining Packet Loss</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eIRgLex-0HFxh0qKBSXolw.png" /></figure><p>Note that, this can only happen when both sides (i.e. client and server) support <em>Selective Acknowledgement. </em>In this case, we see server selectively acknowledging certain sequence numbers, and it does so, by indicating, what blocks of sequence numbers it has successfully received.</p><p><strong>Out of Order Packets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEwv_b6Dx5tF5_GMtaaIxA.png" /></figure><p>Visualizing sequence numbers using Stevens Graph</p><p>(It shows the increase in Sequence numbers in one direction over time)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hwr0ja6VC55d_8RRwqRcDA.png" /></figure><p>(Note, that the sequence number does not change during a TCP retransmission; the sender uses the same sequence number for the retransmitted segment as it did for the original segment.)</p><p><strong>Sequence And Acknowledgement Numbers</strong></p><p>First, TCP 3-way handshake walkthrough,</p><p>Looking at <strong>SYN </strong>packet, things of interest are <strong><em>SYN flag</em></strong>, <strong><em>Window Size value, </em></strong>further in <em>Options, </em>we have <strong><em>Maximum segment size</em></strong>, <strong><em>Window scale, Sack permitted.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogtMAFA4E9Aag0uZ5zjr_g.png" /></figure><p>When we see, the <strong>SYN-ACK </strong>coming back from the server,</p><p><strong><em>39 ms</em></strong>, <strong>MSS</strong> is 1460 , <strong>SACK</strong> is also permitted, and a <strong><em>Window scale</em></strong> of 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YaBzzSfZJKM1GfImWgFxww.png" /></figure><p><strong><em>Ghost bytes</em></strong></p><p>Looking back at SYN packet again, starting sequence number is 0 , and Acknowledgement number is also 0.</p><p>Even though client is not sending legitimate byte of data from client to server, still the <strong><em>Next sequence number</em></strong> is 1 , this is called as Ghost byte.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d7c5hFmOqnGVjvf4eajrcA.png" /></figure><p>Now, when we look at the SYN-ACK from the server, the <strong><em>Acknowledgement number </em></strong>is 1, and the <strong><em>Sequence number</em></strong> is 0. This way, the server is acting as if client sent 1 byte in SYN.</p><p><strong>So each SYN carries, what is called as <em>Ghost Byte</em></strong><em>. </em>It is not a real byte of data, but it causes the opposite side to act as if 1 byte of data was sent.</p><p>This is why <strong>after </strong>the handshakes, we have a sequence number of 1 and acknowledgement number of 1 in both directions.</p><p><strong><em>Packet 4</em></strong></p><p>Further, when we look at following packets , e.g. from client to server,</p><p>client sends a packet that has <em>TCP segment length </em>(i.e. how much encompassed data exists in packet)<em> </em>of 338.</p><p>So 338 bytes of data is sent in the direction (client → server)</p><p>Also, Acknowledgement number is 1 , since the client has NOT received any data yet from the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxUUHc3yae3Ehx0NpS-UEQ.png" /></figure><p><strong><em>Packet5</em></strong><br>Now the server receives the above packet and sends an empty Ack (i.e. no data as evident below in <em>TCP segment</em> column)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tPurKBWQjHrJJWTUP7YhRQ.png" /></figure><p><strong><em>Packet6</em></strong></p><p>sent from Server-&gt; client, and server is actually sending 377 bytes of data.</p><p>So acknowledgement number is still 339 (same as packet 5, since there was no new data received from client), but server is starting to send data, hence the starting sequence number is 1 (in direction from server to client).</p><p>If we add, Sequence number (i.e. 1 ) and TCP Segment Length (i.e. 377),</p><p>we have 1+377 = 378 (which becomes the <strong><em>Next Sequence Number</em></strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GBsJSeAB2iaf7KA_RGvbVQ.png" /></figure><p><strong><em>Packet 7</em></strong></p><p>sent from client-&gt; server</p><p><strong><em>Acknowledgement number</em></strong> is 378, but client is starting on i.e. 339 (<strong><em>Sequence Number</em></strong>), and this time the client is sending 347 bytes (as seen in<strong><em> TCP Segment Len</em></strong>). <br>If we add those 2 numbers together i.e.</p><p><strong><em>Sequence number</em></strong> +<strong><em> TCP Segment Len</em></strong> (i.e bytes of data being sent) , we get the <strong><em>Next Sequence number</em></strong>.</p><p>339 + 347 = 686</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZDM8WPZYIf5RF2mLxlikw.png" /></figure><p>In summary,</p><p>a. This is how sequence and acknowledgement numbers work.</p><p>b. They progressively increment according to the amount of data that is sent in each direction.</p><p>c. Each side will track its sequence numbers.</p><p>d. Each side will acknowledge the other side’s sequence numbers as they increment.</p><p><strong>How does TCP recover from gap in sequence numbers, and how does wireshark flag that ?</strong></p><p>Packet62 -&gt; black line with red letters stating <em>TCP Previous segment not captured , </em>which simply means that packet previous to this packet was not captured in this direction (i.e. from server → client).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMpYnd1GuDenahFIKczPLQ.png" /></figure><p>The previous packet in this direction , is <em>Packet number 60, </em>which says the Next Sequence number is 50777, which further implies that the next packet in <strong>this </strong>direction is 50777.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eiLMbacqUVpYfCFi-sZDwQ.png" /></figure><p>But, if we look back at Packet62 again, the sequence number instead starts with 52237. Hence, wireshark says, there was a gap in sequence number and i am flagging that.</p><p>If we perform 52237- 50777 , we get 1460 bytes, which went missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-2vQiEYc-KgOT3poptv_A.png" /></figure><p>Further, if we look at Packet63, it has Dup Acks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5S-TPwqe2XRuV6hmQzifw.png" /></figure><p>What’s different in Packet63 (i.e. from client -&gt; server) then ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kxbEf_zYTboa7nkfgagPg.png" /></figure><p>Packet63 (i.e. client is saying) is acknowledging everything just before this packet is black and red, as well acknowledging black and red packet too.</p><p>In essence, Packet63 says, the sequence numbers that are missing , fall between the Acknowledgement number that i am sending you and the first number i am sending you in SACK block (i.e. 52237)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sN9dorsh_aXDaakd1HBi4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVuu90fE4r3UPX0tpTs_Fg.png" /></figure><p>This is how the client makes the server aware that it specifically needs to send these missing sequence numbers.</p><p>Once we have packet loss(as we see here), packets that are in-flight will continue to be sent. Client will acknowledge new packets as they come in.</p><p><strong>Interpreting TCP Receive Window</strong></p><p>Questions:</p><ol><li>How to identify TCP SYN packets that did not receive a SYN/ACK ?<br>Ideally, number of SYNs == number of SYN/ACKs. For cases, where we have missing SYN/ACKs , one of the approaches could be, to <br>first filter the packets with <em>tcp.flags.syn == 1, </em>and then navigate to conversation statistics. Once we have the sorted view, the offending ones can be identified by cases, where <em>outgoing </em>exists, but <em>incoming </em>is zero.</li><li>What is Window size ?<br>It advertises what the TCP receive buffer size is.</li><li>Why is the Max value of TCP Window size set to 65,535 bytes?<br>When TCP was standardized, it was never expected that that traffic patterns would ever be so high that it would breach more than 65535 outstanding bytes on the wire.</li><li>Assume the <em>window size</em> value is 30, and the <em>window size scaling factor</em> is 1024, find the <em>calculated window size</em>?<br><em>Calculated window size</em> is 30*1024 = 30,720 bytes</li><li>Window size is how many bits?<br>As explained <a href="https://networklessons.com/cisco/ccnp-route/tcp-window-size-scaling">here</a>, <em>Originally the window size is a 16 bit value so the largest window size would be 65535. Nowadays we use a scaling factor so that we can use larger window sizes</em>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c9526301170" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Async Operations for NetDevOps]]></title>
            <link>https://medium.com/@mailsiddharthtyagi/async-operations-for-netdevops-2c7c0602e92c?source=rss-3131e6dd3372------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c7c0602e92c</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[netdevops]]></category>
            <category><![CDATA[netops]]></category>
            <category><![CDATA[network-automation]]></category>
            <dc:creator><![CDATA[Siddharth Tyagi]]></dc:creator>
            <pubDate>Sun, 09 Feb 2025 13:27:27 GMT</pubDate>
            <atom:updated>2025-05-25T14:56:04.926Z</atom:updated>
            <content:encoded><![CDATA[<p>In day-to-day network operations, some common workstreams are <em>Inventory audits, Automated Device Configuration and Provisioning, Health Monitoring and Alerts, Auto-remediation and recovery scenarios, Configuration Backup and Restore, Automated Software upgrades etc.</em></p><p>Let’s take a scenario, where a fleet of devices has to be scanned to confirm if they are running on a vulnerable OS version. Assume, to fetch the most recent data, one of the team members authors an ad-hoc script that logs into the network devices and fetches the running OS version.</p><p>While this workstream is in progress, one question pops up is — what is the nature of the task ? Is it <a href="https://stackoverflow.com/questions/868568/what-do-the-terms-cpu-bound-and-i-o-bound-mean"><em>I/O Bound or CPU Bound</em></a><em> </em>?</p><p>Priam facie, from what we infer, major bottleneck will be waiting for the result to come back from the network device (i.e output of <em>show version</em>), before the next operation can be performed. Since the CPU does not seem to be a limiting factor here, this will be an I/O bound operation.</p><p>This standalone script can be authored in multiple ways, some of which can be:</p><p>a. Neither threading nor multiprocessing i.e. Sequential</p><p>b. Using threading only</p><p>c. Using multiprocessing only</p><p>Comparison of statistics in terms of turnaround time for each to conclude, for a somewhat similar scenario is described <a href="https://adriangiacometti.net/index.php/2021/05/09/how-to-netmiko-full-speed-concurrency-options/">here</a>. Another related thread is captured <a href="https://stackoverflow.com/questions/59993940/pinging-100-000-servers-is-multithreading-or-multiprocessing-better">here</a>.</p><p>Before we proceed further, it is also relevant to understand the basics in context of <em>sync </em>vs<em> async </em>execution<em>. </em>I came across a simple explanation <a href="https://stackoverflow.com/a/30707667/3471305">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuUxE-d2LlQsEK_G1D38bg.png" /></figure><p>Hence, we could iterate on the above approach and enhance by using likes of <a href="https://docs.python.org/3/library/asyncio.html"><em>asyncio</em></a><em>.</em></p><h4>Why do we care ?</h4><p>Next question, how does it matter whether the operation is <em>async</em> or <em>sync</em> as long as it gets the work done ?</p><p>To some extent it would be fair to say that if the topology size is very small, and negligible operations are performed per device, prima facie, this may not matter. However, as the network(and thus, device count) increases with a corresponding increase in the number of operations performed per device, this becomes a necessity.</p><p>Also, to make this problem even worse, assume an external system is awaiting response (say, a REST API call) of the above program will see even higher delays.</p><p>To summarize, quoting from this <a href="https://stackoverflow.com/questions/27435284/multiprocessing-vs-multithreading-vs-asyncio">thread</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_KMCVvy5zxF6S6tUPGNg0Q.png" /></figure><p>To add to above scenarios, what if we have additional requirements as below:</p><p>a. Handle long-running tasks asynchronously</p><p>b. Support for task prioritization; automatic retries; has locks and rate limiting; result storage</p><p>c. Schedule periodic tasks</p><p>d. Distribute tasks across multiple machines</p><p>e. Manage retries and errors effectively</p><h4>Solution ?</h4><p>Move to a distributed task queue. Some good examples are described in this <a href="https://stackoverflow.com/questions/46517613/python-task-queue-alternatives-and-frameworks">post</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGS-rMEnyCgh-PHd7hZkmQ.png" /></figure><p>I am going ahead with <a href="https://dramatiq.io/"><em>Dramatiq</em></a> as i have some basic experience with <a href="https://docs.celeryq.dev/en/stable/getting-started/first-steps-with-celery.html"><em>Celery</em></a>, and thought of trying something different while i am writing this.</p><p>Most of the differences are captured <a href="https://dramatiq.io/motivation.html#sim">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TCFOIfgAYPiySs37zxKADQ.png" /></figure><h4>Implementation</h4><p><em>Topology</em></p><p>LocalHost running Windows OS.</p><p>VirtualBox installed on LocalHost and R1, R2, R3 are virtual routers spun up using <em>vEoS.</em></p><p><em>R1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7TH2ojdsGOLXOlrgQZ3B-Q.png" /></figure><p><em>R2</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qk_I5-YVhyCBL_AG0MDGMA.png" /></figure><p><em>R3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hby29TKV5_2i17nHOy-IKQ.png" /></figure><p>Python application running on localhost, which can talk to R1, R2,R3 via Bridged Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faVlSE4h3XuVHKERxH-X6g.png" /></figure><p><em>Redis</em></p><p>Next we install <a href="https://github.com/microsoftarchive/redis/releases">Redis</a> as a backend to store messages.</p><p>(For this setup, i used the msi installer shown below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IISiTuqClXpG27UCaFLQfA.png" /></figure><p>Once installed, you should be able to navigate to CLI and start the redis server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mwwIFkpyw8xBjAadltv8A.png" /></figure><p><em>RabbitMQ</em></p><p>Now, we would need a broker, in this case, i used <em>RabbitMq</em>, with installation steps <a href="https://www.youtube.com/watch?v=KhYiaEOrw7Q">here</a>.</p><p>Assuming the installation went fine, to start, you can type in Windows Start menu <em>RabbitMQ service start, </em>which should result in below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NjBbVe2acFjlQFeltfyUpw.png" /></figure><p>You can then navigate to <a href="http://127.0.0.1:15672/"><em>http://127.0.0.1:15672/</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5Tz1afGkfFpCOBq8jmw_Q.png" /></figure><p>Now coming to the actual implementation</p><p>Start the <em>dramatiq</em> worker (in this case, redis actors are hosted in <em>device_operations.py</em>), so we trigger the command <em>dramatiq device_operations</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_56S4wDyWjdcB_MiIL2O_w.png" /></figure><p>Structured response received</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mj4KPuT8SOaFion3ABCe8w.png" /></figure><p>dramatiq workers listening to incoming requests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cfB9OpJA4HULmZBCPogqg.png" /></figure><p>This data can be further ingested to a database. For simplicity, i have used <em>SqliteDb</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjJDdf3uHKiAEECLOfaQ9A.png" /></figure><p>Now, to fetch devices running on a specific OS version, we can just execute,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jTEEr9GEbwu-VMC_plpPQ.png" /></figure><p><em>Code snippets</em></p><p><em>app.py</em></p><pre>import time<br>from collections import defaultdict<br>from device_operations import fetch_uptime, fetch_free_memory, fetch_os_version<br>from data_ingestor import ingest<br>import dramatiq<br>import ipaddress<br><br>devices = [&quot;10.10.10.2&quot;,&quot;10.10.10.3&quot;,&quot;10.10.10.4&quot;]<br><br>task_list = [fetch_uptime, fetch_free_memory, fetch_os_version]<br><br>def get_result_with_timeout(message, timeout=5):<br>    host_mgmt_ip = message.args[0] if message.args else &quot;Missing&quot;<br>    start_time = time.time()    <br>    while True:        <br>        try:<br>            if time.time() - start_time &gt; timeout:<br>                raise TimeoutError(&quot;Task processing timed out&quot;) <br>            result = message.get_result()<br>            break<br>        except dramatiq.results.errors.ResultMissing:<br>            print(f&quot;{message} still processing&quot;)<br>    return {host_mgmt_ip:result}<br><br>def get_multiple_results(messages):<br>    results = []<br>    for message in messages:<br>        result = get_result_with_timeout(message)<br>        results.append(result)<br>    return results<br><br>def main():    <br>    try:    <br>        task_ids = []<br>        for task in task_list:<br>            # assuming the mgmt IPs are valid<br>            for device in devices:<br>                task_ids.append(task.send(device))        <br><br>        results = get_multiple_results(task_ids)<br>        formatted_results = convert_raw_to_structured(results)<br>        for entity, list_with_values in formatted_results.items():<br>            uptime = free_memory = version = None<br>            for data in list_with_values:<br>                uptime = data.get(&quot;Uptime&quot;, uptime)<br>                free_memory = data.get(&quot;FreeMemory&quot;, free_memory)<br>                version = data.get(&quot;Version&quot;, version)<br>            entities_of_interest = {<br>                &#39;MgmtIp&#39;: entity,<br>                &#39;Uptime&#39;: uptime,<br>                &#39;FreeMemory&#39;: free_memory,<br>                &#39;Version&#39;: version<br>            }<br>            ingest(entities_of_interest)<br>    except Exception as e:<br>        print(f&quot;Error occurred: {str(e)}&quot;)<br><br>def convert_raw_to_structured(list_of_dictionaries):<br>    result = defaultdict(list)<br>    for dictionary in list_of_dictionaries:<br>        for ip, data in dictionary.items():<br>            result[ip].append(data)<br>    return result <br>   <br>    <br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p><em>device_connector.py</em></p><pre>from netmiko import ConnectHandler<br>from netmiko.exceptions import NetMikoTimeoutException, NetMikoAuthenticationException<br>import keyring, logging<br>logging.basicConfig(filename=&#39;v_lab.log&#39;, level=logging.DEBUG)<br>logger = logging.getLogger(&quot;netmiko&quot;)<br><br>def _fetch_credential():<br>    cred = keyring.get_credential(&quot;VirtualLab&quot;,&quot;&quot;)<br>    return cred<br><br>def get_connector(ip, device_type = &quot;arista_eos&quot;):<br>    try:<br>        _device = {<br>            &#39;device_type&#39;: device_type,<br>            &#39;ip&#39;: ip,<br>            &#39;username&#39;: _fetch_credential().username,<br>            &#39;password&#39;: _fetch_credential().password<br>        }<br><br>        net_connect = ConnectHandler(**_device)        <br>    except NetMikoTimeoutException:        <br>        logger.exception(f&quot;For device {ip}, connection timed out&quot;)<br>    except NetMikoAuthenticationException:        <br>        logger.exception(f&quot;For device {ip}, authentication failed&quot;)<br>    except Exception as e:<br>        logger.exception(f&quot;For device {ip},error occurred: {str(e)}&quot;)<br>    else:<br>        logger.debug(&quot;Connected to device {}&quot;.format(ip))<br>        return net_connect<br>    logger.debug(&quot;Failed to connect to device {}&quot;.format(ip))<br>    return None</pre><p><em>device_operations.py</em></p><pre>import dramatiq<br>import json<br>from device_connector import get_connector<br>from dramatiq.brokers.rabbitmq import RabbitmqBroker<br>from dramatiq.results.backends.redis import RedisBackend<br>from dramatiq.results import Results<br>import requests<br><br>result_backend = RedisBackend(host=&quot;127.0.0.1&quot;, port=6379)<br>broker = RabbitmqBroker(url=&quot;amqp://guest:guest@localhost:5672&quot;)<br>broker.add_middleware(Results(backend=result_backend))<br>dramatiq.set_broker(broker)<br><br><br>CMD_VERSION = &quot;show version | json&quot;<br><br>@dramatiq.actor(store_results=True)<br>def fetch_uptime(ip):<br>    session_handler = get_connector(ip)<br>    if session_handler is not None:<br>        return {&#39;Uptime&#39;:json.loads(session_handler.send_command(CMD_VERSION))[&#39;uptime&#39;]}<br><br>@dramatiq.actor(store_results=True)<br>def fetch_free_memory(ip):<br>    session_handler = get_connector(ip)<br>    if session_handler is not None:<br>        return {&#39;FreeMemory&#39;:json.loads(session_handler.send_command(CMD_VERSION))[&#39;memFree&#39;]}<br><br>@dramatiq.actor(store_results=True)<br>def fetch_os_version(ip):<br>    session_handler = get_connector(ip)<br>    if session_handler is not None:<br>        return {&#39;Version&#39;:json.loads(session_handler.send_command(CMD_VERSION))[&#39;version&#39;]}</pre><p><em>data_ingestor.py</em></p><pre>import sqlite3<br><br><br>def ingest(data, db=&quot;v_labs.db&quot;,table=&quot;DeviceData&quot;):<br>    connection = sqlite3.connect(db)<br>    cursor = connection.cursor()<br>    cursor.execute(f&#39;INSERT OR REPLACE INTO {table} values \<br>     (?,?,?,?)&#39;, \<br>        [data[&#39;MgmtIp&#39;], data[&#39;Uptime&#39;], data[&#39;FreeMemory&#39;], data[&#39;Version&#39;]])<br>    connection.commit()<br>    print(f&quot;Table {table} updated successfully&quot;);<br>    connection.close()<br><br>ingest(data)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c7c0602e92c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>