Skip to content

Commit 835b58f

Browse files
IDT v0.0.2 (project-chip#29931)
* Squashed commit of the following: commit 29d46b1 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 21:48:48 2023 -0700 Nit commit b432937 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 21:11:22 2023 -0700 README and error reporting and controlelr resturct commit 4ac762d Author: bozowski <bozowski@google.com> Date: Mon Oct 23 19:15:59 2023 -0700 Logging commit 5b6b325 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 18:38:25 2023 -0700 Move logging commit 9df3206 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 18:13:57 2023 -0700 Prober commit 4683b34 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 17:55:03 2023 -0700 Make logcat resiliant commit 12bb816 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 17:30:37 2023 -0700 Warn when file is not growing commit 1451a02 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 16:03:36 2023 -0700 Real time analysis commit 8c8ac7f Author: bozowski <bozowski@google.com> Date: Mon Oct 23 12:22:00 2023 -0700 Fix capabilities, screen commit 6ccfcc7 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 11:27:38 2023 -0700 Snoop commit 29d8969 Author: bozowski <bozowski@google.com> Date: Mon Oct 23 11:12:26 2023 -0700 HCI logs commit a856bf6 Author: bozowski <bozowski@google.com> Date: Fri Oct 20 15:04:32 2023 -0700 Fix pull commit 1239a90 Author: bozowski <bozowski@google.com> Date: Fri Oct 20 14:51:22 2023 -0700 OK commit 2b3db4d Author: bozowski <bozowski@google.com> Date: Fri Oct 20 14:09:16 2023 -0700 Screen recording commit 5d02aa6 Author: bozowski <bozowski@google.com> Date: Fri Oct 20 13:34:05 2023 -0700 Nits commit 85517ff Author: bozowski <bozowski@google.com> Date: Fri Oct 20 13:07:40 2023 -0700 Fix prober, color config commit c5d668c Author: bozowski <bozowski@google.com> Date: Fri Oct 20 12:45:20 2023 -0700 Screen commit 6352581 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 21:39:05 2023 -0700 Nit commit 1c8a45a Author: bozowski <bozowski@google.com> Date: Thu Oct 19 21:22:14 2023 -0700 Nit commit 51c187f Author: bozowski <bozowski@google.com> Date: Thu Oct 19 21:10:07 2023 -0700 Splash commit 0091588 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 20:47:48 2023 -0700 Refactor commit c480a02 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 15:41:39 2023 -0700 Refactor commit 024eeb6 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 15:27:05 2023 -0700 Bugreport commit efcc621 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 14:51:30 2023 -0700 Nit commit d5474b7 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 14:33:18 2023 -0700 Configs commit 0fcbb10 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 04:26:54 2023 -0700 TODO commit b1c7a30 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 04:20:18 2023 -0700 Clean BUILD commit d86778a Author: bozowski <bozowski@google.com> Date: Thu Oct 19 04:16:19 2023 -0700 Logging bug commit 6ebf7c0 Author: bozowski <bozowski@google.com> Date: Thu Oct 19 03:03:48 2023 -0700 Branch * Restyled by prettier-markdown * Restyled by shellharden * Restyled by autopep8 * Restyled by isort * Spelling * Lints * Support RPi install * Restyled by prettier-markdown * Uneeded sudo * Readme clarification * Remove dead comment * Remove dead comment * Squashed commit of the following: commit 36f3ceb Author: Austin Bozowski <bozowski@google.com> Date: Wed Oct 25 20:07:16 2023 -0700 Multiproc to async and target macOS * Fix stopping procs on mac * Replace multiproc with async * Fix sudo kill issue on macOS * Note * Fix stopping pcap issue on macOS * Cleanup * BLE scanning on macOS * Final cleanup for macOS and README * Squashed commit of the following: commit 3da0875 Author: Austin Bozowski <bozowski@google.com> Date: Fri Nov 3 01:49:45 2023 -0700 README commit b7d115d Author: Austin Bozowski <bozowski@google.com> Date: Fri Nov 3 01:44:58 2023 -0700 Refactor commit b9dca9d Author: Austin Bozowski <bozowski@google.com> Date: Fri Nov 3 01:16:11 2023 -0700 Refactor commit d960b41 Author: Austin Bozowski <bozowski@google.com> Date: Fri Nov 3 00:43:21 2023 -0700 Logging commit 4f6644c Author: Austin Bozowski <bozowski@google.com> Date: Fri Nov 3 00:18:11 2023 -0700 Discovery commit 6900a19 Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 23:55:17 2023 -0700 README commit f2e9a8c Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 23:44:15 2023 -0700 README commit dc98974 Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 23:27:02 2023 -0700 Write dnssd log commit 1fe3f98 Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 22:34:32 2023 -0700 Cleanup probers commit 5e48bc0 Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 14:55:03 2023 -0700 Probes commit c9d14ed Author: Austin Bozowski <bozowski@google.com> Date: Thu Nov 2 13:22:21 2023 -0700 Probers commit 12307e4 Author: Austin Bozowski <bozowski@google.com> Date: Wed Nov 1 15:43:31 2023 -0700 Earlier prober * Nits * Remove temp tests * Prevent re run of Bash proc and nits * Restyled by prettier-markdown * Restyled by autopep8 * Restyled by isort * Spelling * Lint * Respond comment. * Comment and rename * Nits * Clarify * Add info on interfaces to README * Document failure mode of not allowing bt perms in macOS * Restyled by prettier-markdown * Restyled by isort * Verify py version and fix non py dep check * Move host dependencies back to main * Fix py version check * Make task cleanup more graceful * Nit * Respond comments * Ensure which is available in host_platform * Add mac tcpdump build script thanks to James Rename timeout config and explain it in comments Slight change to where timeouts are in controller * README * Logging * Explain all DNS SD content to the user (parse TXT etc.) * Remove TODO * TTL and nits * Logging, limit tracert, nits * Restyled by prettier-markdown * Restyled by shellharden * Restyled by shfmt * Restyled by autopep8 * Restyled by isort * Integrate mac android tcp and bump restyle * Use termcolor for colored logs * Timeout config documentation * Remove unnecessary abstractions from controller * Cleanup py version check * Cleanup error reporting in controller * Remove unneeded instance vars in playservices * Fix logcat file scope issue introd in last commit * Fix dedent * Add bison to Dockerfile * Make screen on check in android explicit * Restyled by autopep8 * Restyled by isort --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent c76fcda commit 835b58f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2444
-585
lines changed

src/tools/interop/idt/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ __pycache__/
77
pycache/
88
venv/
99
.zip
10+
BUILD

src/tools/interop/idt/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ RUN apt-get update && \
2121
adb \
2222
aircrack-ng \
2323
apt-utils \
24+
bison \
25+
byacc \
26+
dnsutils \
27+
flex \
28+
gcc-aarch64-linux-gnu \
29+
gcc-arm-linux-gnueabi \
2430
git \
2531
glib-2.0 \
2632
kmod \

src/tools/interop/idt/README.md

+131-78
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,32 @@ issue uncovered via the manual test. Each ecosystem may implement an analysis
2929
that analyzes capture data, displays info to the user, probes the local
3030
environment and generates additional artifacts.
3131

32-
## Getting started
32+
## Single host installation (no Raspberry Pi)
33+
34+
All features of `idt` are available on macOS and Linux (tested with Debian based
35+
systems).
36+
If you would prefer to execute capture and discovery from a Raspberry Pi, read
37+
the next section instead.
38+
39+
The machine running `idt` should be connected to the same Wi-Fi network used for
40+
testing.
41+
Follow the steps below to execute capture and discovery without a Raspberry Pi:
42+
43+
- From the parent directory of `idt`, run `source idt/scripts/alias.sh`.
44+
- Optionally, run `source idt/scripts/setup_shell.sh` to install aliases
45+
permanently.
46+
- After `idt` aliases are available in your environment, calling any `idt`
47+
command will automatically create a new virtual environment and install
48+
python dependencies.
49+
- If you're missing non-Python dependencies, you'll be prompted to install
50+
them until they're available.
51+
- Bluetooth discovery on macOS will require granting the program where `idt`
52+
is run, e.g. terminal emulator or IDE permission to access bluetooth in
53+
macOS settings.
54+
- Failure to do so may result in any of the following:
55+
- A single `abort` message and no further output in the terminal.
56+
- Failure with a relevant stack trace in the terminal.
57+
- A prompt to allow the application access to bluetooth.
3358

3459
## Raspberry Pi installation
3560

@@ -137,62 +162,21 @@ idt_clean
137162
```
138163
139164
NOTE the idt artifacts directory is contained in idt, so running this will
140-
delete any artifacts ([TODO] change).
165+
delete any artifacts.
141166
142167
Then from the admin computer:
143168
144169
```
145170
idt_push
146171
```
147172
148-
## Single host installation (no Raspberry Pi)
149-
150-
Follow the steps below to execute capture and discovery without a Raspberry Pi.
151-
152-
### Linux installation
153-
154-
#### Requirements
155-
156-
- This package should work on most Debian (/based) systems.
157-
- `idt` is currently tested on `Python 3.11`.
158-
- `adb` and `tcpdump` are required.
159-
- The machine running `idt` should be connected to the same Wi-Fi network used
160-
for testing.
161-
162-
#### Setup
163-
164-
- From the parent directory of `idt`, run `source idt/scripts/alias.sh`.
165-
- Optionally, run `source idt/scripts/setup_shell.sh` to install aliases
166-
permanently.
167-
168-
> You may use `idt` in a Python virtual environment OR using a container from
169-
> the idt image.
170-
171-
#### Python virtual environment
172-
173-
- After `idt` aliases are available in your environment, calling any `idt`
174-
command will automatically create a new virtual environment and install
175-
dependencies.
176-
177-
#### Docker
178-
179-
- Run `idt_build` and `idt_activate` to enter the `idt` container.
180-
181-
[TODO] Podman
182-
183-
### macOS installation
184-
185-
Most features other than BLE should work on macOS.
186-
187-
Follow the Linux installation steps above, but do not use Docker.
188-
189-
[TODO] macOS BLE support
190-
191173
## User guide
192174
193175
> **_IMPORTANT_**
194176
> `idt_` commands are shell aliases helpful for administrative commands.
195-
> `idt` invokes the `idt` python package.
177+
> `idt` invokes the `idt` python package.
178+
> Output from `idt` will generally be colorized while output from sub processes
179+
> is generally not.
196180
197181
RPi users, as needed:
198182
@@ -208,45 +192,38 @@ RPi users, as needed:
208192
209193
### Capture
210194
195+
> **_IMPORTANT_**
196+
> Ensure you've made it to the log line "Starting real time analysis, press
197+
> enter to stop!" before launching the app under test.
198+
211199
```
212200
idt capture -h
213201

214-
usage: idt capture [-h] [--platform {Android}]
215-
[--ecosystem {PlayServices,PlayServicesUser,ALL}]
216-
[--pcap {t,f}]
217-
[--interface {wlp0s20f3,docker0,lo}]
218-
[--additional {t,f}]
202+
usage: idt capture [-h] [--platform {Android}] [--ecosystem {PlayServicesUser,PlayServices,ALL}] [--pcap {t,f}] [--interface {wlp0s20f3,lo,docker0,any}]
219203

220204
options:
221205
-h, --help show this help message and exit
222206
--platform {Android}, -p {Android}
223-
Run capture for a particular platform
224-
(default Android)
225-
--ecosystem {PlayServices,PlayServicesUser,ALL}, -e {PlayServices,PlayServicesUser,ALL}
226-
Run capture for a particular ecosystem or ALL
227-
ecosystems (default ALL)
207+
Run capture for a particular platform (default Android)
208+
--ecosystem {PlayServicesUser,PlayServices,ALL}, -e {PlayServicesUser,PlayServices,ALL}
209+
Run capture for a particular ecosystem or ALL ecosystems (default ALL)
228210
--pcap {t,f}, -c {t,f}
229211
Run packet capture (default t)
230-
--interface {wlp0s20f3,docker0,lo}, -i {wlp0s20f3,docker0,lo}
231-
Run packet capture against a specified
232-
interface (default wlp0s20f3)
233-
--additional {t,f}, -a {t,f}
234-
Run ble and mdns scanners in the background
235-
while capturing (default t)
212+
--interface {wlp0s20f3,lo,docker0,any}, -i {wlp0s20f3,lo,docker0,any}
213+
Specify packet capture interface (default any)
236214
```
237215
216+
For packet capture interface (`-i`/`--interface`:
217+
218+
- On macOS, the only available interface is `any`.
219+
- On Linux, `idt` checks available interfaces from `/sys/class/net/` as well
220+
as allowing `any`.
221+
238222
#### Artifacts
239223
240224
Each ecosystem and platform involved in the capture will have their own
241225
subdirectory in the root artifact dir.
242226
243-
To download your artifacts, run these commands from your admin computer:
244-
245-
`idt_fetch_artifacts`
246-
247-
On windows admin computers, you may use `FileZilla` to pull the archive listed
248-
at the end of output.
249-
250227
### Discovery
251228
252229
```
@@ -260,7 +237,7 @@ options:
260237
Specify the type of discovery to execute
261238
```
262239
263-
#### ble
240+
#### BLE
264241
265242
```
266243
idt discover -t b
@@ -274,13 +251,90 @@ idt discover -t d
274251
275252
#### Artifacts
276253
277-
There is a per device log for ble scanning in `ble` subdirectory of the root
278-
artifact dir.
254+
There is a per device log in `ble` and `dnssd` subdirectory of the root artifact
255+
dir.
256+
257+
### Probe
258+
259+
```
260+
usage: idt probe [-h]
261+
262+
options:
263+
-h, --help show this help message and exit
264+
```
279265
280-
[TODO] dnssd per device log
266+
Collect contextually relevant networking info from the local environment and
267+
provide artifacts.
268+
269+
## Troubleshooting
270+
271+
- Wireless `adb` may fail to connect indefinitely depending on network
272+
configuration. Use a wired connection if wireless fails repeatedly.
273+
- Change log level from `INFO` to `DEBUG` in root `config.py` for additional
274+
logging.
275+
- Compiling `tcpdump` for android may require additional dependencies.
276+
- If the build script fails for you, try
277+
`idt_go && source idt/scripts/compilers.sh`.
278+
- You may disable colors and splash by setting `enable_color` in `config.py`
279+
to `False`.
280+
- `idt_clean_child` will kill any stray `tcpdump` and `adb` commands.
281+
- `idt_check_child` will look for leftover processes.
282+
- Not expected to be needed outside of development scenarios.
283+
284+
## Project overview
285+
286+
- The entry point is in `idt.py` which contains simple CLI parsing with
287+
`argparse`.
288+
289+
### `capture`
290+
291+
- `base` contains the base classes for ecosystems and platforms.
292+
- `controller` contains the ecosystem and platform producer and controller
293+
- `loader` is a generic class loader that dynamically imports classes matching
294+
a given super class from a given directory.
295+
- `/platform` and `/ecosystem` contain one package for each platform and
296+
ecosystem, which should each contain one implementation of the respective
297+
base class.
298+
299+
### `discovery`
300+
301+
- `matter_ble` provides a simple ble scanner that shows matter devices being
302+
discovered and lost, as well as their VID/PID, RSSI, etc.
303+
- `matter_dnssd` provides a simple DNS-SD browser that searches for matter
304+
devices and thread border routers.
305+
306+
### `probe`
307+
308+
- `probe` contains the base class for (`idt`'s) host platform specific
309+
implementation.
310+
- Reuses the dnssd discovery implementation to build probe targets.
311+
- Calls platform + addr type specific probe methods for each target.
312+
- `linux` and `mac` contain `probe` implementations for each host platform.
313+
314+
### `utils`
315+
316+
- `log` contains logging utilities used by everything in the project.
317+
- `artifact` contains helper functions for managing artifacts.
318+
- `shell` contains a simple helper class for background and foreground Bash
319+
commands.
320+
- `host_platform` contains helper functions for the interacting with the host
321+
running `idt`.
322+
323+
### Conventions
324+
325+
- `config.py` should be used to hold development configs within the directory
326+
where they are needed.
327+
- It may also hold configs for flaky/cumbersome features that might need
328+
to be disabled in an emergency.
329+
- `config.py` **should not** be used for everyday operation.
330+
- When needed, execute builds in a folder called `BUILD` within the source
331+
tree.
332+
- `idt_clean_all` deletes all `BUILD` dirs and `BUILD` is in `.gitignore`.
281333
282334
## Extending functionality
283335
336+
### Capture
337+
284338
Ecosystem and Platform implementations are dynamically loaded.
285339
286340
For each package in `capture/ecosystem`, the ecosystem loader expects a module
@@ -299,14 +353,13 @@ $ idt capture -h
299353
usage: idt capture [-h] [--platform {Android}] [--ecosystem {DemoExtEcosystem...
300354
```
301355
356+
> **IMPORTANT:** Note the following runtime expectations of ecosystems:
357+
> `analyze_capture()` must not block the async event loop excessively and must
358+
> not interact with standard in
359+
302360
The platform loader functions the same as `capture/ecosystem`.
303361
304362
For each package in `capture/platform`, the platform loader expects a module
305363
name matching the package name.
306364
This module must contain a single class which is a subclass of
307365
`capture.base.PlatformLogStreamer`.
308-
309-
Note the following runtime expectations of platforms:
310-
311-
- Start should be able to be called repeatedly without restarting streaming.
312-
- Stop should not cause an error even if the stream is not running.

src/tools/interop/idt/__main__.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#
1717

1818
from idt import InteropDebuggingTool
19+
from utils.host_platform import verify_py_version
1920

2021
if __name__ == "__main__":
22+
verify_py_version()
2123
InteropDebuggingTool()

src/tools/interop/idt/capture/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717

1818
from capture import ecosystem, platform
1919

20-
from .factory import EcosystemCapture, EcosystemController, EcosystemFactory, PlatformFactory, PlatformLogStreamer
20+
from .controller import EcosystemCapture, PlatformLogStreamer
2121
from .pcap import PacketCaptureRunner
2222

2323
__all__ = [
2424
'ecosystem',
2525
'platform',
26+
'controller',
2627
'EcosystemCapture',
27-
'EcosystemController',
28-
'EcosystemFactory',
2928
'PacketCaptureRunner',
30-
'PlatformFactory',
3129
'PlatformLogStreamer',
3230
]

0 commit comments

Comments
 (0)