|
1 | | -# Datasets |
| 1 | +# IQB Static Data Files |
2 | 2 |
|
3 | | -A set of sample datasets. |
| 3 | +This directory contains static measurement data used by |
| 4 | +the IQB prototype for Phase 1 development. |
| 5 | + |
| 6 | +## Current Dataset |
| 7 | + |
| 8 | +**Period**: October 2024 (2024-10-01 to 2024-10-31) |
| 9 | + |
| 10 | +**Source**: [M-Lab NDT](https://www.measurementlab.net/tests/ndt/) unified views |
| 11 | + |
| 12 | +**Countries**: United States (US), Germany (DE), Brazil (BR) |
| 13 | + |
| 14 | +### Files |
| 15 | + |
| 16 | +- `us_2024_10.json` - United States, ~31M download samples, ~24M upload samples |
| 17 | + |
| 18 | +- `de_2024_10.json` - Germany, ~7M download samples, ~4M upload samples |
| 19 | + |
| 20 | +- `br_2024_10.json` - Brazil, ~5M download samples, ~3M upload samples |
| 21 | + |
| 22 | +### Data Structure |
| 23 | + |
| 24 | +Each JSON file contains: |
| 25 | + |
| 26 | +```JavaScript |
| 27 | +{ |
| 28 | + "metadata": { |
| 29 | + "country_code": "US", |
| 30 | + "country_name": "United States", |
| 31 | + "period": "2024-10", |
| 32 | + "period_description": "October 2024", |
| 33 | + "dataset": "M-Lab NDT", |
| 34 | + "download_samples": 31443312, |
| 35 | + "upload_samples": 24288961 |
| 36 | + }, |
| 37 | + "metrics": { |
| 38 | + "download_throughput_mbps": {"p1": 0.38, /* ... */, "p99": 891.82}, |
| 39 | + "upload_throughput_mbps": {"p1": 0.06, /* ... */, "p99": 813.73}, |
| 40 | + "latency_ms": {"p1": 0.16, /* ... */, "p99": 254.34}, |
| 41 | + "packet_loss": {"p1": 0.0, /* ... */, "p99": 0.25} |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +**Percentiles included**: p1, p5, p10, p25, p50, p75, p90, p95, p99 |
| 47 | + |
| 48 | +## How This Data Was Generated |
| 49 | + |
| 50 | +### BigQuery Queries |
| 51 | + |
| 52 | +The data was extracted from M-Lab's public BigQuery tables using two queries: |
| 53 | + |
| 54 | +1. **Downloads** (`query_downloads.sql`): Queries |
| 55 | +`measurement-lab.ndt.unified_downloads` for: |
| 56 | + |
| 57 | + - Download throughput (`a.MeanThroughputMbps`) |
| 58 | + |
| 59 | + - Latency (`a.MinRTT`) |
| 60 | + |
| 61 | + - Packet loss (`a.LossRate`) |
| 62 | + |
| 63 | +2. **Uploads** (`query_uploads.sql`): Queries |
| 64 | +`measurement-lab.ndt.unified_uploads` for: |
| 65 | + |
| 66 | + - Upload throughput (`a.MeanThroughputMbps`) |
| 67 | + |
| 68 | +### Running the Data Generation Pipeline |
| 69 | + |
| 70 | +**Prerequisites**: |
| 71 | + |
| 72 | +- Google Cloud SDK (`gcloud`) installed |
| 73 | + |
| 74 | +- BigQuery CLI (`bq`) installed |
| 75 | + |
| 76 | +- `gcloud`-authenticated with an account subscribed to |
| 77 | +[M-Lab Discuss mailing list](https://groups.google.com/a/measurementlab.net/g/discuss) |
| 78 | + |
| 79 | +- Python 3.11+ |
| 80 | + |
| 81 | +**Complete Pipeline** (recommended): |
| 82 | + |
| 83 | +```bash |
| 84 | +cd data/ |
| 85 | +python3 generate_data.py |
| 86 | +``` |
| 87 | + |
| 88 | +This orchestrates the complete pipeline: |
| 89 | + |
| 90 | +1. Queries BigQuery for download metrics (throughput, latency, packet loss) |
| 91 | + |
| 92 | +2. Queries BigQuery for upload metrics (throughput) |
| 93 | + |
| 94 | +3. Merges the data into per-country JSON files |
| 95 | + |
| 96 | +Generated files: `us_2024_10.json`, `de_2024_10.json`, `br_2024_10.json`. |
| 97 | + |
| 98 | +**Individual Pipeline Stages** (for debugging): |
| 99 | + |
| 100 | +```bash |
| 101 | +cd data/ |
| 102 | + |
| 103 | +# Stage 1a: Query downloads |
| 104 | +python3 run_query.py query_downloads.sql -o downloads.json |
| 105 | + |
| 106 | +# Stage 1b: Query uploads |
| 107 | +python3 run_query.py query_uploads.sql -o uploads.json |
| 108 | + |
| 109 | +# Stage 2: Merge data |
| 110 | +python3 merge_data.py |
| 111 | +``` |
| 112 | + |
| 113 | +**Pipeline Scripts**: |
| 114 | + |
| 115 | +- [generate_data.py](generate_data.py) - Orchestrates the complete pipeline |
| 116 | + |
| 117 | +- [run_query.py](run_query.py) - Executes a BigQuery query and saves results |
| 118 | + |
| 119 | +- [merge_data.py](merge_data.py) - Merges download and upload data into |
| 120 | +per-country files |
| 121 | + |
| 122 | +### Modifying Queries |
| 123 | + |
| 124 | +To change the time period or countries, edit the SQL files: |
| 125 | + |
| 126 | +```sql |
| 127 | +WHERE |
| 128 | + date BETWEEN "2024-10-01" AND "2024-10-31" -- Change dates here |
| 129 | + AND client.Geo.CountryCode IN ("US", "DE", "BR") -- Change countries here |
| 130 | +``` |
| 131 | + |
| 132 | +Country codes follow the |
| 133 | +[ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) standard. |
| 134 | + |
| 135 | +## Notes |
| 136 | + |
| 137 | +- **Static data**: These files contain pre-aggregated percentiles |
| 138 | +for Phase 1 prototype. Phase 2 will add dynamic data fetching. |
| 139 | + |
| 140 | +- **Time granularity**: Data is aggregated over the entire |
| 141 | +month (October 2024). The analyst decides which time window |
| 142 | +to use when fethcing data for running IQB calculations. |
| 143 | + |
| 144 | +- **Percentile selection**: The Streamlit UI allows users |
| 145 | +to select which percentile(s) to use for IQB score calculations. |
| 146 | + |
| 147 | +- **File size**: Each file is ~1.4KB (uncompressed). No |
| 148 | +compression needed. |
| 149 | + |
| 150 | +## M-Lab NDT Data Schema |
| 151 | + |
| 152 | +M-Lab provides two unified views: |
| 153 | + |
| 154 | +- `measurement-lab.ndt.unified_downloads` - Download tests |
| 155 | + |
| 156 | +- `measurement-lab.ndt.unified_uploads` - Upload tests |
| 157 | + |
| 158 | +Key fields used: |
| 159 | + |
| 160 | +- `a.MeanThroughputMbps` - Mean throughput in Mbps |
| 161 | + |
| 162 | +- `a.MinRTT` - Minimum round-trip time in milliseconds |
| 163 | + |
| 164 | +- `a.LossRate` - Packet loss rate (0.0-1.0) |
| 165 | + |
| 166 | +- `client.Geo.CountryCode` - ISO country code |
| 167 | + |
| 168 | +- `date` - Measurement date (YYYY-MM-DD) |
| 169 | + |
| 170 | +See [M-Lab NDT documentation](https://www.measurementlab.net/tests/ndt/#ndt-data-in-bigquery) |
| 171 | +for details. |
| 172 | + |
| 173 | +## Future Improvements (Phase 2+) |
| 174 | + |
| 175 | +- Dynamic data fetching from BigQuery |
| 176 | + |
| 177 | +- Support for additional datasets (Ookla, Cloudflare) |
| 178 | + |
| 179 | +- Finer time granularity (daily, weekly) |
| 180 | + |
| 181 | +- Sub-national geographic resolution (cities, ASNs) |
| 182 | + |
| 183 | +- Local database integration for caching aggregated data |
0 commit comments