CML Packet Capture
MCP Server
- Command:
cml-mcp (pip-installed, stdio transport)
- Requires:
CML_URL, CML_USERNAME, CML_PASSWORD environment variables
Available Tools
Packet Capture Operations
| Tool |
Parameters |
What It Does |
start_capture |
lab_id/lab_title, link_id, max_packets?, pcap_filter? |
Start capturing packets on a link |
stop_capture |
lab_id/lab_title, link_id |
Stop an active capture |
get_capture_status |
lab_id/lab_title, link_id |
Check capture status (running, packet count) |
download_capture |
lab_id/lab_title, link_id, file_path? |
Download the captured pcap file |
list_captures |
lab_id/lab_title |
List all active and completed captures in a lab |
Workflow: Capture and Analyze (Full Pipeline)
When a user says "capture traffic between R1 and R2 and analyze it":
- Find the link: Use
get_links (from cml-topology-builder) to find the link ID between R1 and R2
- Start capture:
start_capture with optional filter (e.g., "icmp", "tcp port 179")
- Generate traffic: Tell the user to generate traffic (or use
execute_command to ping)
- Stop capture:
stop_capture after sufficient traffic is collected
- Download pcap:
download_capture to save the pcap file locally
- Analyze with Packet Buddy: Hand off to the packet-analysis skill:
pcap_summary — overview
pcap_protocol_hierarchy — protocol breakdown
pcap_conversations — who talked to whom
pcap_expert_info — errors, retransmissions
pcap_filter — drill into specific traffic
- Report findings: Summarize the analysis in plain English
Workflow: Targeted Protocol Capture
When troubleshooting a specific protocol:
BGP Troubleshooting
1. start_capture with pcap_filter="tcp port 179"
2. Wait for BGP events (or trigger with clear ip bgp)
3. stop_capture
4. download_capture
5. Analyze: Look for OPEN, KEEPALIVE, UPDATE, NOTIFICATION messages
6. Check for: hold timer expiry, capability mismatch, prefix limit exceeded
OSPF Troubleshooting
1. start_capture with pcap_filter="ospf"
2. Wait for OSPF events (or trigger with clear ip ospf process)
3. stop_capture
4. download_capture
5. Analyze: Look for Hello, DBD, LSR, LSU, LSAck packets
6. Check for: area mismatch, auth failure, MTU mismatch, dead timer expiry
ICMP / Connectivity
1. start_capture (no filter, or pcap_filter="icmp")
2. execute_command on source node: "ping {destination}"
3. stop_capture
4. download_capture
5. Analyze: Look for echo request/reply, unreachable, TTL exceeded
6. Check for: asymmetric routing, ACL drops, MTU issues
Spanning Tree
1. start_capture with pcap_filter="stp"
2. Wait for STP convergence or trigger topology change
3. stop_capture
4. download_capture
5. Analyze: BPDUs, topology change notifications, root bridge elections
Capture Filters
CML uses BPF (Berkeley Packet Filter) syntax for capture filters:
| Filter |
Captures |
icmp |
ICMP (ping) traffic |
tcp port 179 |
BGP traffic |
ospf |
OSPF traffic |
tcp port 22 |
SSH traffic |
udp port 53 |
DNS traffic |
arp |
ARP requests/replies |
stp |
Spanning Tree BPDUs |
tcp port 80 or tcp port 443 |
HTTP/HTTPS traffic |
host 10.0.0.1 |
Traffic to/from specific host |
net 10.0.0.0/24 |
Traffic to/from specific subnet |
vlan 100 |
Traffic on VLAN 100 |
Workflow: Compare Before/After
When verifying a configuration change:
- Capture before: Start capture, collect baseline traffic
- Stop and download: Save as
before.pcap
- Make the change: Apply configuration via cml-node-operations
- Capture after: Start new capture, collect post-change traffic
- Stop and download: Save as
after.pcap
- Compare: Analyze both pcaps with Packet Buddy
- Report: Document the differences (e.g., "BGP converged in 3s after route-map change")
Integration with Packet Buddy
After downloading a pcap from CML, use these Packet Buddy tools for analysis:
| Step |
Packet Buddy Tool |
Purpose |
| 1 |
pcap_summary |
Big picture: packet count, duration, size |
| 2 |
pcap_protocol_hierarchy |
What protocols are present |
| 3 |
pcap_conversations |
Who is talking to whom |
| 4 |
pcap_expert_info |
Errors, warnings, retransmissions |
| 5 |
pcap_filter |
Focus on specific traffic |
| 6 |
pcap_packet_detail |
Deep dive into a single packet |
| 7 |
pcap_dns_queries |
DNS resolution analysis |
| 8 |
pcap_http_requests |
HTTP traffic analysis |
Important Rules
- Lab must be running — captures only work on links in a started lab
- One capture per link — stop an existing capture before starting a new one
- Use filters for busy links — unfiltered captures on high-traffic links can be large
- Set max_packets — prevent runaway captures; 10000 packets is usually enough
- Download before stopping — some CML versions clear the capture buffer on link state change
- File naming: Save pcaps with descriptive names like
r1-r2-bgp-capture.pcap
- Record in GAIT — log captures and findings for audit trail
1---
2name: cml-packet-capture
3description: "CML packet capture — start, stop, download pcaps from CML lab links, integrate with Packet Buddy for analysis. Use when capturing packets in a CML lab, troubleshooting BGP or OSPF with packet analysis, or downloading pcap files for Wireshark review."
4version: 1.0.0
5license: Apache-2.0
6tags: [cml, pcap, capture, troubleshooting, wireshark]
7---
8
9# CML Packet Capture
10
11## MCP Server
12
13- **Command**: `cml-mcp` (pip-installed, stdio transport)
14- **Requires**: `CML_URL`, `CML_USERNAME`, `CML_PASSWORD` environment variables
15
16## Available Tools
17
18### Packet Capture Operations
19
20| Tool | Parameters | What It Does |
21|------|-----------|-------------|
22| `start_capture` | `lab_id`/`lab_title`, `link_id`, `max_packets?`, `pcap_filter?` | Start capturing packets on a link |
23| `stop_capture` | `lab_id`/`lab_title`, `link_id` | Stop an active capture |
24| `get_capture_status` | `lab_id`/`lab_title`, `link_id` | Check capture status (running, packet count) |
25| `download_capture` | `lab_id`/`lab_title`, `link_id`, `file_path?` | Download the captured pcap file |
26| `list_captures` | `lab_id`/`lab_title` | List all active and completed captures in a lab |
27
28## Workflow: Capture and Analyze (Full Pipeline)
29
30When a user says "capture traffic between R1 and R2 and analyze it":
31
321. **Find the link**: Use `get_links` (from cml-topology-builder) to find the link ID between R1 and R2
332. **Start capture**: `start_capture` with optional filter (e.g., "icmp", "tcp port 179")
343. **Generate traffic**: Tell the user to generate traffic (or use `execute_command` to ping)
354. **Stop capture**: `stop_capture` after sufficient traffic is collected
365. **Download pcap**: `download_capture` to save the pcap file locally
376. **Analyze with Packet Buddy**: Hand off to the packet-analysis skill:
38 - `pcap_summary` — overview
39 - `pcap_protocol_hierarchy` — protocol breakdown
40 - `pcap_conversations` — who talked to whom
41 - `pcap_expert_info` — errors, retransmissions
42 - `pcap_filter` — drill into specific traffic
437. **Report findings**: Summarize the analysis in plain English
44
45## Workflow: Targeted Protocol Capture
46
47When troubleshooting a specific protocol:
48
49### BGP Troubleshooting
50```
511. start_capture with pcap_filter="tcp port 179"
522. Wait for BGP events (or trigger with clear ip bgp)
533. stop_capture
544. download_capture
555. Analyze: Look for OPEN, KEEPALIVE, UPDATE, NOTIFICATION messages
566. Check for: hold timer expiry, capability mismatch, prefix limit exceeded
57```
58
59### OSPF Troubleshooting
60```
611. start_capture with pcap_filter="ospf"
622. Wait for OSPF events (or trigger with clear ip ospf process)
633. stop_capture
644. download_capture
655. Analyze: Look for Hello, DBD, LSR, LSU, LSAck packets
666. Check for: area mismatch, auth failure, MTU mismatch, dead timer expiry
67```
68
69### ICMP / Connectivity
70```
711. start_capture (no filter, or pcap_filter="icmp")
722. execute_command on source node: "ping {destination}"
733. stop_capture
744. download_capture
755. Analyze: Look for echo request/reply, unreachable, TTL exceeded
766. Check for: asymmetric routing, ACL drops, MTU issues
77```
78
79### Spanning Tree
80```
811. start_capture with pcap_filter="stp"
822. Wait for STP convergence or trigger topology change
833. stop_capture
844. download_capture
855. Analyze: BPDUs, topology change notifications, root bridge elections
86```
87
88## Capture Filters
89
90CML uses BPF (Berkeley Packet Filter) syntax for capture filters:
91
92| Filter | Captures |
93|--------|----------|
94| `icmp` | ICMP (ping) traffic |
95| `tcp port 179` | BGP traffic |
96| `ospf` | OSPF traffic |
97| `tcp port 22` | SSH traffic |
98| `udp port 53` | DNS traffic |
99| `arp` | ARP requests/replies |
100| `stp` | Spanning Tree BPDUs |
101| `tcp port 80 or tcp port 443` | HTTP/HTTPS traffic |
102| `host 10.0.0.1` | Traffic to/from specific host |
103| `net 10.0.0.0/24` | Traffic to/from specific subnet |
104| `vlan 100` | Traffic on VLAN 100 |
105
106## Workflow: Compare Before/After
107
108When verifying a configuration change:
109
1101. **Capture before**: Start capture, collect baseline traffic
1112. **Stop and download**: Save as `before.pcap`
1123. **Make the change**: Apply configuration via cml-node-operations
1134. **Capture after**: Start new capture, collect post-change traffic
1145. **Stop and download**: Save as `after.pcap`
1156. **Compare**: Analyze both pcaps with Packet Buddy
1167. **Report**: Document the differences (e.g., "BGP converged in 3s after route-map change")
117
118## Integration with Packet Buddy
119
120After downloading a pcap from CML, use these Packet Buddy tools for analysis:
121
122| Step | Packet Buddy Tool | Purpose |
123|------|-------------------|---------|
124| 1 | `pcap_summary` | Big picture: packet count, duration, size |
125| 2 | `pcap_protocol_hierarchy` | What protocols are present |
126| 3 | `pcap_conversations` | Who is talking to whom |
127| 4 | `pcap_expert_info` | Errors, warnings, retransmissions |
128| 5 | `pcap_filter` | Focus on specific traffic |
129| 6 | `pcap_packet_detail` | Deep dive into a single packet |
130| 7 | `pcap_dns_queries` | DNS resolution analysis |
131| 8 | `pcap_http_requests` | HTTP traffic analysis |
132
133## Important Rules
134
135- **Lab must be running** — captures only work on links in a started lab
136- **One capture per link** — stop an existing capture before starting a new one
137- **Use filters for busy links** — unfiltered captures on high-traffic links can be large
138- **Set max_packets** — prevent runaway captures; 10000 packets is usually enough
139- **Download before stopping** — some CML versions clear the capture buffer on link state change
140- **File naming**: Save pcaps with descriptive names like `r1-r2-bgp-capture.pcap`
141- **Record in GAIT** — log captures and findings for audit trail