Skip to content

Instantly share code, notes, and snippets.

@dhalperi
Created November 4, 2023 01:29
Show Gist options
  • Save dhalperi/2db8b46ebff98eb4d3fbb97aed823af3 to your computer and use it in GitHub Desktop.
Save dhalperi/2db8b46ebff98eb4d3fbb97aed823af3 to your computer and use it in GitHub Desktop.
Jupyter notebook repro for batfish/batfish#8859
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8c999b48-b4fd-47b2-a901-2b3b8f9bb06e",
"metadata": {},
"outputs": [],
"source": [
"from pybatfish.client.session import Session\n",
"from pybatfish.datamodel import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1774c358-0caa-49d4-94a3-bc2e8da4a82c",
"metadata": {},
"outputs": [],
"source": [
"bf = Session()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "0a103564-8fda-4786-b4f2-865bab3cc883",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'pcpe880862e-a0d0-45ac-8e3e-126e263525e7'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bf.set_network()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "968141ed-00c3-439d-8acd-097b86035a59",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'ss_99c970a2-a665-4a4c-9583-05589b595313'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bf.init_snapshot('/Users/dhalperi/networks/github-8859/')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "90eae831-bf41-410a-b504-3e3101fc66fd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>File_Name</th>\n",
" <th>Status</th>\n",
" <th>File_Format</th>\n",
" <th>Nodes</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>configs/dev1</td>\n",
" <td>PASSED</td>\n",
" <td>CISCO_IOS</td>\n",
" <td>['dev1']</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>configs/dev2</td>\n",
" <td>PASSED</td>\n",
" <td>CISCO_IOS</td>\n",
" <td>['dev2']</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>configs/dev3</td>\n",
" <td>PASSED</td>\n",
" <td>CISCO_IOS</td>\n",
" <td>['dev3']</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>configs/dev4</td>\n",
" <td>PASSED</td>\n",
" <td>CISCO_IOS</td>\n",
" <td>['dev4']</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>configs/dev5</td>\n",
" <td>PASSED</td>\n",
" <td>CISCO_IOS</td>\n",
" <td>['dev5']</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" File_Name Status File_Format Nodes\n",
"0 configs/dev1 PASSED CISCO_IOS ['dev1']\n",
"1 configs/dev2 PASSED CISCO_IOS ['dev2']\n",
"2 configs/dev3 PASSED CISCO_IOS ['dev3']\n",
"3 configs/dev4 PASSED CISCO_IOS ['dev4']\n",
"4 configs/dev5 PASSED CISCO_IOS ['dev5']"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bf.q.fileParseStatus().answer().frame()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "466c2610-16c6-42e6-b305-2ce28d0e1c45",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Flow</th>\n",
" <th>Traces</th>\n",
" <th>TraceCount</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>start=dev1 [10.0.12.1:49152-&gt;10.0.45.5:33434 UDP]</td>\n",
" <td>[((ORIGINATED(default), FORWARDED(Forwarded ou...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Flow \\\n",
"0 start=dev1 [10.0.12.1:49152->10.0.45.5:33434 UDP] \n",
"\n",
" Traces TraceCount \n",
"0 [((ORIGINATED(default), FORWARDED(Forwarded ou... 1 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tr = bf.q.traceroute(startLocation='dev1', headers=HeaderConstraints(dstIps='10.0.45.5')).answer().frame()\n",
"tr"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f90bd2f9-42de-49c2-8014-908534ec663a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"color:#019612; text-weight:bold;\">ACCEPTED</span><br><strong>1</strong>. node: dev1<br>&nbsp;&nbsp;ORIGINATED(default)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>2</strong>. node: dev2<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>3</strong>. node: dev3<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.34.4)])<br>&nbsp;&nbsp;TRANSFORMED(SOURCE_NAT srcIp: 10.0.12.1 -> 20.0.12.1)<br>&nbsp;&nbsp;SETUP_SESSION(Incoming Interfaces: [GigabitEthernet0/1], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=20.0.12.1, srcPort=33434, dstPort=49152], Transformation: [dstIp: 20.0.12.1 -> 10.0.12.1])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>4</strong>. node: dev4<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>5</strong>. node: dev5<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;ACCEPTED(GigabitEthernet0/0)"
],
"text/plain": [
"ListWrapper([((ORIGINATED(default), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.34.4)]), TRANSFORMED(SOURCE_NAT srcIp: 10.0.12.1 -> 20.0.12.1), SETUP_SESSION(Incoming Interfaces: [GigabitEthernet0/1], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=20.0.12.1, srcPort=33434, dstPort=49152], Transformation: [dstIp: 20.0.12.1 -> 10.0.12.1]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), ACCEPTED(GigabitEthernet0/0)))])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tr.Traces[0]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "2181936b-fb7c-467f-b062-b3c22ede77ce",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Forward_Flow</th>\n",
" <th>Forward_Traces</th>\n",
" <th>New_Sessions</th>\n",
" <th>Reverse_Flow</th>\n",
" <th>Reverse_Traces</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>start=dev1 [10.0.12.1:49152-&gt;10.0.45.5:33434 UDP]</td>\n",
" <td>[((ORIGINATED(default), FORWARDED(Forwarded ou...</td>\n",
" <td>['dev3']</td>\n",
" <td>start=dev5 [10.0.45.5:33434-&gt;20.0.12.1:49152 UDP]</td>\n",
" <td>[((ORIGINATED(default), FORWARDED(Forwarded ou...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Forward_Flow \\\n",
"0 start=dev1 [10.0.12.1:49152->10.0.45.5:33434 UDP] \n",
"\n",
" Forward_Traces New_Sessions \\\n",
"0 [((ORIGINATED(default), FORWARDED(Forwarded ou... ['dev3'] \n",
"\n",
" Reverse_Flow \\\n",
"0 start=dev5 [10.0.45.5:33434->20.0.12.1:49152 UDP] \n",
"\n",
" Reverse_Traces \n",
"0 [((ORIGINATED(default), FORWARDED(Forwarded ou... "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr = bf.q.bidirectionalTraceroute(startLocation='dev1', headers=HeaderConstraints(dstIps='10.0.45.5')).answer().frame()\n",
"btr"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "900d1133-e25f-4c4c-a1fa-f82eab4ae774",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"color:#019612; text-weight:bold;\">ACCEPTED</span><br><strong>1</strong>. node: dev1<br>&nbsp;&nbsp;ORIGINATED(default)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>2</strong>. node: dev2<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>3</strong>. node: dev3<br>&nbsp;&nbsp;RECEIVED(inside)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: outside with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: interface outside ip 10.0.34.4)])<br>&nbsp;&nbsp;PERMITTED(~COMBINED_OUTGOING_ACL~outside~ (PRE_TRANSFORMATION_EGRESS_FILTER))<br>&nbsp;&nbsp;SETUP_SESSION(Incoming Interfaces: [outside], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=10.0.12.1, srcPort=33434, dstPort=49152])<br>&nbsp;&nbsp;TRANSMITTED(outside)<br><strong>4</strong>. node: dev4<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>5</strong>. node: dev5<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;ACCEPTED(GigabitEthernet0/0)"
],
"text/plain": [
"ListWrapper([((ORIGINATED(default), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(inside), FORWARDED(Forwarded out interface: outside with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: interface outside ip 10.0.34.4)]), PERMITTED(~COMBINED_OUTGOING_ACL~outside~ (PRE_TRANSFORMATION_EGRESS_FILTER)), SETUP_SESSION(Incoming Interfaces: [outside], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=10.0.12.1, srcPort=33434, dstPort=49152]), TRANSMITTED(outside)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), ACCEPTED(GigabitEthernet0/0)))])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Forward_Traces[0]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "79cdb991-7949-4c98-81b1-48ce448f4045",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"color:#019612; text-weight:bold;\">ACCEPTED</span><br><strong>1</strong>. node: dev5<br>&nbsp;&nbsp;ORIGINATED(default)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.45.4, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.45.4)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>2</strong>. node: dev4<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.34.3, Routes: [static (Network: 20.0.12.0/24, Next Hop: ip 10.0.34.3)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>3</strong>. node: dev3<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;MATCHED_SESSION(Incoming Interfaces: [GigabitEthernet0/1], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=20.0.12.1, srcPort=33434, dstPort=49152], Transformation: [dstIp: 20.0.12.1 -> 10.0.12.1])<br>&nbsp;&nbsp;TRANSFORMED(DEST_NAT dstIp: 20.0.12.1 -> 10.0.12.1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.23.2, Routes: [static (Network: 10.0.12.0/24, Next Hop: ip 10.0.23.2)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>4</strong>. node: dev2<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0, Routes: [connected (Network: 10.0.12.0/24, Next Hop: interface GigabitEthernet0/0)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>5</strong>. node: dev1<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;ACCEPTED(GigabitEthernet0/1)"
],
"text/plain": [
"ListWrapper([((ORIGINATED(default), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.45.4, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.45.4)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.34.3, Routes: [static (Network: 20.0.12.0/24, Next Hop: ip 10.0.34.3)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), MATCHED_SESSION(Incoming Interfaces: [GigabitEthernet0/1], Action: PostNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.45.5, dstIp=20.0.12.1, srcPort=33434, dstPort=49152], Transformation: [dstIp: 20.0.12.1 -> 10.0.12.1]), TRANSFORMED(DEST_NAT dstIp: 20.0.12.1 -> 10.0.12.1), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.23.2, Routes: [static (Network: 10.0.12.0/24, Next Hop: ip 10.0.23.2)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), FORWARDED(Forwarded out interface: GigabitEthernet0/0, Routes: [connected (Network: 10.0.12.0/24, Next Hop: interface GigabitEthernet0/0)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), ACCEPTED(GigabitEthernet0/1)))])"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Reverse_Traces[0]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "5820fbd9-b4c7-483f-86ea-b5540176ad05",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Filename</th>\n",
" <th>Line</th>\n",
" <th>Text</th>\n",
" <th>Parser_Context</th>\n",
" <th>Comment</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [Filename, Line, Text, Parser_Context, Comment]\n",
"Index: []"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bf.q.parseWarning().answer()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "aed0a349-e9b1-41fa-929d-2e447a4cf68a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Nodes</th>\n",
" <th>Source_Lines</th>\n",
" <th>Type</th>\n",
" <th>Details</th>\n",
" <th>Line_Text</th>\n",
" <th>Parser_Context</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [Nodes, Source_Lines, Type, Details, Line_Text, Parser_Context]\n",
"Index: []"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bf.q.initIssues().answer()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "662e46e9-f348-49db-9a1a-641e8e4fa198",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Forward_Flow</th>\n",
" <th>Forward_Traces</th>\n",
" <th>New_Sessions</th>\n",
" <th>Reverse_Flow</th>\n",
" <th>Reverse_Traces</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>start=dev5 [10.0.45.5:49152-&gt;20.0.12.1:33434 UDP]</td>\n",
" <td>[((ORIGINATED(default), FORWARDED(Forwarded ou...</td>\n",
" <td>['dev3']</td>\n",
" <td>start=dev1 [10.0.12.1:33434-&gt;10.0.45.5:49152 UDP]</td>\n",
" <td>[((ORIGINATED(default), FORWARDED(Forwarded ou...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Forward_Flow \\\n",
"0 start=dev5 [10.0.45.5:49152->20.0.12.1:33434 UDP] \n",
"\n",
" Forward_Traces New_Sessions \\\n",
"0 [((ORIGINATED(default), FORWARDED(Forwarded ou... ['dev3'] \n",
"\n",
" Reverse_Flow \\\n",
"0 start=dev1 [10.0.12.1:33434->10.0.45.5:49152 UDP] \n",
"\n",
" Reverse_Traces \n",
"0 [((ORIGINATED(default), FORWARDED(Forwarded ou... "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr = bf.q.bidirectionalTraceroute(startLocation='dev5', headers=HeaderConstraints(dstIps='20.0.12.1')).answer().frame()\n",
"btr"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "95459e02-e6aa-4271-bc5a-c9caf2a92870",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 start=dev5 [10.0.45.5:49152->20.0.12.1:33434 UDP]\n",
"Name: Forward_Flow, dtype: object"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Forward_Flow"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "3f5381ca-a8ec-40d5-b647-81ac6ad9bdf8",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"color:#019612; text-weight:bold;\">ACCEPTED</span><br><strong>1</strong>. node: dev5<br>&nbsp;&nbsp;ORIGINATED(default)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.45.4, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.45.4)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>2</strong>. node: dev4<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.34.3, Routes: [static (Network: 20.0.12.0/24, Next Hop: ip 10.0.34.3)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>3</strong>. node: dev3<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;TRANSFORMED(DEST_NAT dstIp: 20.0.12.1 -> 10.0.12.1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.23.2, Routes: [static (Network: 10.0.12.0/24, Next Hop: ip 10.0.23.2)])<br>&nbsp;&nbsp;SETUP_SESSION(Incoming Interfaces: [GigabitEthernet0/0], Action: PreNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.12.1, dstIp=10.0.45.5, srcPort=33434, dstPort=49152], Transformation: [srcIp: 10.0.12.1 -> 20.0.12.1])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>4</strong>. node: dev2<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/0, Routes: [connected (Network: 10.0.12.0/24, Next Hop: interface GigabitEthernet0/0)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/0)<br><strong>5</strong>. node: dev1<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/1)<br>&nbsp;&nbsp;ACCEPTED(GigabitEthernet0/1)"
],
"text/plain": [
"ListWrapper([((ORIGINATED(default), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.45.4, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.45.4)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.34.3, Routes: [static (Network: 20.0.12.0/24, Next Hop: ip 10.0.34.3)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), TRANSFORMED(DEST_NAT dstIp: 20.0.12.1 -> 10.0.12.1), FORWARDED(Forwarded out interface: GigabitEthernet0/0 with resolved next-hop IP: 10.0.23.2, Routes: [static (Network: 10.0.12.0/24, Next Hop: ip 10.0.23.2)]), SETUP_SESSION(Incoming Interfaces: [GigabitEthernet0/0], Action: PreNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.12.1, dstIp=10.0.45.5, srcPort=33434, dstPort=49152], Transformation: [srcIp: 10.0.12.1 -> 20.0.12.1]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), FORWARDED(Forwarded out interface: GigabitEthernet0/0, Routes: [connected (Network: 10.0.12.0/24, Next Hop: interface GigabitEthernet0/0)]), TRANSMITTED(GigabitEthernet0/0)), (RECEIVED(GigabitEthernet0/1), ACCEPTED(GigabitEthernet0/1)))])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Forward_Traces[0]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "50f28590-b8ba-4859-88ca-771c9de42e99",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 start=dev1 [10.0.12.1:33434->10.0.45.5:49152 UDP]\n",
"Name: Reverse_Flow, dtype: object"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Reverse_Flow"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "3c9d5ef5-2435-4885-a226-cb36310f3644",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<span style=\"color:#019612; text-weight:bold;\">ACCEPTED</span><br><strong>1</strong>. node: dev1<br>&nbsp;&nbsp;ORIGINATED(default)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>2</strong>. node: dev2<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>3</strong>. node: dev3<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;MATCHED_SESSION(Incoming Interfaces: [GigabitEthernet0/0], Action: PreNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.12.1, dstIp=10.0.45.5, srcPort=33434, dstPort=49152], Transformation: [srcIp: 10.0.12.1 -> 20.0.12.1])<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.34.4)])<br>&nbsp;&nbsp;TRANSFORMED(SOURCE_NAT srcIp: 10.0.12.1 -> 20.0.12.1)<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>4</strong>. node: dev4<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)])<br>&nbsp;&nbsp;TRANSMITTED(GigabitEthernet0/1)<br><strong>5</strong>. node: dev5<br>&nbsp;&nbsp;RECEIVED(GigabitEthernet0/0)<br>&nbsp;&nbsp;ACCEPTED(GigabitEthernet0/0)"
],
"text/plain": [
"ListWrapper([((ORIGINATED(default), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.12.2, Routes: [static (Network: 0.0.0.0/0, Next Hop: ip 10.0.12.2)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.23.3, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.23.3)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), MATCHED_SESSION(Incoming Interfaces: [GigabitEthernet0/0], Action: PreNatFibLookup, Match Criteria: [ipProtocol=UDP, srcIp=10.0.12.1, dstIp=10.0.45.5, srcPort=33434, dstPort=49152], Transformation: [srcIp: 10.0.12.1 -> 20.0.12.1]), FORWARDED(Forwarded out interface: GigabitEthernet0/1 with resolved next-hop IP: 10.0.34.4, Routes: [static (Network: 10.0.45.0/24, Next Hop: ip 10.0.34.4)]), TRANSFORMED(SOURCE_NAT srcIp: 10.0.12.1 -> 20.0.12.1), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), FORWARDED(Forwarded out interface: GigabitEthernet0/1, Routes: [connected (Network: 10.0.45.0/24, Next Hop: interface GigabitEthernet0/1)]), TRANSMITTED(GigabitEthernet0/1)), (RECEIVED(GigabitEthernet0/0), ACCEPTED(GigabitEthernet0/0)))])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"btr.Reverse_Traces[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8ae3194-18c2-4b82-a534-7e1181833fce",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment