protocols = [
{
name: "Bluetooth LE (BLE)",
category: "Short-range",
range_m: [1, 100],
data_rate_kbps: [125, 2000],
power: "ultra-low",
latency_ms: [3, 50],
cost_hw: 3,
cost_recurring: 0,
security: "AES-128",
topology: ["Point-to-point", "Star", "Mesh (BLE 5)"],
standards: ["Bluetooth SIG"],
strengths: ["Ubiquitous smartphone support", "Low power", "Mesh capability (5.0+)"],
weaknesses: ["Limited range", "Interference in 2.4GHz"],
best_for: ["Wearables", "Smart home", "Beacons", "Health monitoring"]
},
{
name: "Wi-Fi (802.11)",
category: "Short-range",
range_m: [10, 100],
data_rate_kbps: [11000, 1000000],
power: "high",
latency_ms: [1, 10],
cost_hw: 5,
cost_recurring: 0,
security: "WPA3",
topology: ["Star", "Mesh"],
standards: ["IEEE 802.11"],
strengths: ["High bandwidth", "Ubiquitous infrastructure", "IP-native"],
weaknesses: ["High power consumption", "Not ideal for battery devices"],
best_for: ["Cameras", "Smart displays", "Gateways", "High-bandwidth sensors"]
},
{
name: "Wi-Fi HaLow (802.11ah)",
category: "Short-range",
range_m: [100, 1000],
data_rate_kbps: [150, 86700],
power: "medium",
latency_ms: [10, 100],
cost_hw: 8,
cost_recurring: 0,
security: "WPA3",
topology: ["Star"],
standards: ["IEEE 802.11ah"],
strengths: ["Extended range Wi-Fi", "Better penetration (sub-GHz)", "IP-native"],
weaknesses: ["Limited availability", "Higher cost than standard Wi-Fi"],
best_for: ["Smart buildings", "Industrial sensors", "Outdoor IoT"]
},
{
name: "Zigbee",
category: "Short-range mesh",
range_m: [10, 100],
data_rate_kbps: [20, 250],
power: "low",
latency_ms: [15, 100],
cost_hw: 4,
cost_recurring: 0,
security: "AES-128",
topology: ["Mesh", "Star", "Tree"],
standards: ["IEEE 802.15.4", "Zigbee Alliance"],
strengths: ["Self-healing mesh", "Low power", "Large networks (65K nodes)"],
weaknesses: ["Not IP-native", "Gateway required", "2.4GHz interference"],
best_for: ["Smart home", "Building automation", "Industrial sensors"]
},
{
name: "Thread",
category: "Short-range mesh",
range_m: [10, 100],
data_rate_kbps: [20, 250],
power: "low",
latency_ms: [10, 100],
cost_hw: 5,
cost_recurring: 0,
security: "AES-128, DTLS",
topology: ["Mesh"],
standards: ["IEEE 802.15.4", "Thread Group", "Matter"],
strengths: ["IP-native (IPv6)", "Self-healing mesh", "Matter compatible"],
weaknesses: ["Newer ecosystem", "Limited legacy support"],
best_for: ["Smart home (Matter)", "Building automation", "Consumer IoT"]
},
{
name: "Z-Wave",
category: "Short-range mesh",
range_m: [30, 100],
data_rate_kbps: [9.6, 100],
power: "low",
latency_ms: [50, 200],
cost_hw: 8,
cost_recurring: 0,
security: "AES-128 (S2)",
topology: ["Mesh"],
standards: ["Z-Wave Alliance", "ITU-T G.9959"],
strengths: ["Sub-GHz (less interference)", "Strong smart home ecosystem"],
weaknesses: ["Proprietary", "Lower data rate", "Regional frequencies"],
best_for: ["Smart home", "Security systems", "HVAC control"]
},
{
name: "LoRaWAN",
category: "LPWAN",
range_m: [2000, 15000],
data_rate_kbps: [0.3, 50],
power: "ultra-low",
latency_ms: [1000, 10000],
cost_hw: 10,
cost_recurring: 0.5,
security: "AES-128 (E2E)",
topology: ["Star-of-stars"],
standards: ["LoRa Alliance"],
strengths: ["Excellent range", "Very low power", "Open ecosystem"],
weaknesses: ["Low bandwidth", "High latency", "Duty cycle limits"],
best_for: ["Smart agriculture", "Asset tracking", "Smart cities", "Utilities"]
},
{
name: "Sigfox",
category: "LPWAN",
range_m: [3000, 50000],
data_rate_kbps: [0.1, 0.6],
power: "ultra-low",
latency_ms: [2000, 30000],
cost_hw: 5,
cost_recurring: 1,
security: "AES-128",
topology: ["Star"],
standards: ["Sigfox (proprietary)"],
strengths: ["Extreme range", "Ultra-low power", "Simple protocol"],
weaknesses: ["Very limited bandwidth", "Operator dependent", "Downlink limited"],
best_for: ["Simple telemetry", "Asset tracking", "Smoke detectors"]
},
{
name: "NB-IoT",
category: "Cellular LPWAN",
range_m: [1000, 35000],
data_rate_kbps: [20, 250],
power: "low",
latency_ms: [1500, 10000],
cost_hw: 15,
cost_recurring: 2,
security: "LTE security",
topology: ["Star"],
standards: ["3GPP Release 13+"],
strengths: ["Carrier infrastructure", "Deep coverage", "Secure"],
weaknesses: ["Subscription costs", "Latency", "Power for mobility"],
best_for: ["Smart meters", "Asset tracking", "Remote monitoring"]
},
{
name: "LTE-M (Cat-M1)",
category: "Cellular LPWAN",
range_m: [1000, 35000],
data_rate_kbps: [375, 1000],
power: "medium",
latency_ms: [10, 100],
cost_hw: 20,
cost_recurring: 3,
security: "LTE security",
topology: ["Star"],
standards: ["3GPP Release 13+"],
strengths: ["Voice support", "Mobility support", "Higher bandwidth than NB-IoT"],
weaknesses: ["Higher power than NB-IoT", "Subscription costs"],
best_for: ["Wearables", "Fleet tracking", "Connected health"]
},
{
name: "5G NR (IoT)",
category: "Cellular",
range_m: [100, 10000],
data_rate_kbps: [1000, 10000000],
power: "high",
latency_ms: [1, 10],
cost_hw: 50,
cost_recurring: 10,
security: "5G security",
topology: ["Star"],
standards: ["3GPP Release 15+"],
strengths: ["Ultra-low latency", "Massive capacity", "Network slicing"],
weaknesses: ["High power", "High cost", "Limited coverage currently"],
best_for: ["Industrial automation", "Autonomous vehicles", "AR/VR"]
},
{
name: "NFC",
category: "Very short-range",
range_m: [0, 0.1],
data_rate_kbps: [106, 424],
power: "ultra-low",
latency_ms: [1, 10],
cost_hw: 1,
cost_recurring: 0,
security: "Secure Element",
topology: ["Point-to-point"],
standards: ["ISO 14443", "ISO 18092"],
strengths: ["Instant connection", "No pairing needed", "Very low power"],
weaknesses: ["Touch range only", "Low bandwidth"],
best_for: ["Payments", "Access control", "Device pairing", "Tags"]
},
{
name: "RFID (UHF)",
category: "Very short-range",
range_m: [0, 12],
data_rate_kbps: [40, 640],
power: "passive",
latency_ms: [1, 50],
cost_hw: 0.1,
cost_recurring: 0,
security: "Basic",
topology: ["Star"],
standards: ["EPC Gen2", "ISO 18000-6C"],
strengths: ["No battery needed", "Very cheap tags", "Bulk reading"],
weaknesses: ["Reader infrastructure needed", "Limited security"],
best_for: ["Inventory tracking", "Supply chain", "Access control"]
},
{
name: "Ethernet",
category: "Wired",
range_m: [0, 100],
data_rate_kbps: [10000, 10000000],
power: "N/A (wired)",
latency_ms: [0.1, 1],
cost_hw: 5,
cost_recurring: 0,
security: "MACsec, TLS",
topology: ["Star", "Bus"],
standards: ["IEEE 802.3"],
strengths: ["Reliable", "High bandwidth", "Low latency", "PoE available"],
weaknesses: ["Wiring required", "Not mobile"],
best_for: ["Industrial", "Building backbone", "Gateways", "Cameras"]
}
];
// Scoring algorithm
function scoreProtocol(protocol, requirements) {
let score = 50; // Base score
let reasons = [];
let warnings = [];
// Range scoring
const rangeNeed = requirements.range;
const [minRange, maxRange] = protocol.range_m;
if (rangeNeed <= maxRange && rangeNeed >= minRange * 0.5) {
score += 15;
reasons.push(`Range ${minRange}-${maxRange}m fits your ${rangeNeed}m need`);
} else if (rangeNeed > maxRange) {
score -= 25;
warnings.push(`Max range ${maxRange}m may be insufficient for ${rangeNeed}m`);
} else if (rangeNeed < minRange * 0.3) {
score -= 5;
warnings.push(`Overkill for ${rangeNeed}m (min range ${minRange}m)`);
}
// Power scoring
if (requirements.powerCritical) {
if (protocol.power === "ultra-low" || protocol.power === "passive") {
score += 20;
reasons.push("Excellent battery life");
} else if (protocol.power === "low") {
score += 10;
reasons.push("Good battery life");
} else if (protocol.power === "high") {
score -= 20;
warnings.push("High power consumption - not ideal for battery");
}
}
// Bandwidth scoring
const [minBw, maxBw] = protocol.data_rate_kbps;
if (requirements.bandwidth <= maxBw && requirements.bandwidth >= minBw * 0.1) {
score += 10;
reasons.push(`Bandwidth ${minBw}-${maxBw} kbps suitable`);
} else if (requirements.bandwidth > maxBw) {
score -= 30;
warnings.push(`Max ${maxBw} kbps insufficient for ${requirements.bandwidth} kbps need`);
}
// Latency scoring
const [minLat, maxLat] = protocol.latency_ms;
if (requirements.latency >= maxLat) {
score += 10;
reasons.push("Latency acceptable");
} else if (requirements.latency < minLat) {
score -= 20;
warnings.push(`Min latency ${minLat}ms exceeds ${requirements.latency}ms requirement`);
}
// Cost scoring
if (requirements.lowCost) {
if (protocol.cost_hw <= 5 && protocol.cost_recurring <= 0.5) {
score += 10;
reasons.push("Cost-effective option");
} else if (protocol.cost_hw > 20 || protocol.cost_recurring > 3) {
score -= 10;
warnings.push("Higher cost solution");
}
}
// Infrastructure scoring
if (requirements.hasWifi && protocol.name.includes("Wi-Fi")) {
score += 10;
reasons.push("Leverages existing Wi-Fi infrastructure");
}
if (requirements.hasCellular && protocol.category.includes("Cellular")) {
score += 10;
reasons.push("Uses available cellular coverage");
}
// Security scoring
if (requirements.highSecurity) {
if (protocol.security.includes("AES") || protocol.security.includes("TLS") || protocol.security.includes("LTE")) {
score += 10;
reasons.push(`Strong security: ${protocol.security}`);
}
}
// Scalability scoring
if (requirements.highScale) {
if (protocol.topology.includes("Mesh") || protocol.category.includes("LPWAN") || protocol.category.includes("Cellular")) {
score += 10;
reasons.push("Good scalability");
}
}
// Indoor/Outdoor scoring
if (requirements.outdoor && protocol.category.includes("LPWAN")) {
score += 10;
reasons.push("Excellent outdoor penetration");
}
if (requirements.indoor && (protocol.name === "Zigbee" || protocol.name === "Thread" || protocol.name.includes("Wi-Fi"))) {
score += 5;
reasons.push("Good indoor coverage");
}
return {
...protocol,
score: Math.max(0, Math.min(100, score)),
reasons: reasons,
warnings: warnings
};
}
// Parse requirements from form inputs
requirements = {
// Range parsing
let range = 50; // default
if (range_need.includes("< 1 meter")) range = 0.5;
else if (range_need.includes("1-10 meters")) range = 10;
else if (range_need.includes("10-100 meters")) range = 100;
else if (range_need.includes("100m - 1 km")) range = 500;
else if (range_need.includes("1-15 km")) range = 10000;
else if (range_need.includes("15+ km")) range = 30000;
else if (range_need.includes("Mobile")) range = 5000;
// Bandwidth parsing
let bandwidth = 10; // kbps default
if (bandwidth_need.includes("< 100 bytes")) bandwidth = 0.01;
else if (bandwidth_need.includes("10 KB")) bandwidth = 1;
else if (bandwidth_need.includes("1 MB")) bandwidth = 100;
else if (bandwidth_need.includes("100 MB")) bandwidth = 10000;
else if (bandwidth_need.includes("> 100 MB")) bandwidth = 100000;
// Latency parsing
let latency = 1000; // ms default
if (latency_need.includes("< 10 ms")) latency = 10;
else if (latency_need.includes("10-100 ms")) latency = 100;
else if (latency_need.includes("100 ms - 1 s")) latency = 1000;
else if (latency_need.includes("1-10 seconds")) latency = 10000;
else if (latency_need.includes("minutes-hours")) latency = 100000;
// Power critical?
let powerCritical = power_source.includes("years") || power_source.includes("5-10") || power_source.includes("harvesting");
// Low cost?
let lowCost = budget.includes("Minimal") || budget.includes("Low");
// Infrastructure
let hasWifi = infrastructure.includes("Wi-Fi");
let hasCellular = infrastructure.includes("Cellular");
// Security
let highSecurity = security_level.includes("High") || security_level.includes("Critical");
// Scalability
let highScale = device_count.includes("1,000") || device_count.includes("10,000");
// Environment
let outdoor = environment.includes("Outdoor") || environment.includes("Agricultural") || environment.includes("Urban");
let indoor = environment.includes("Indoor") || environment.includes("Office");
return {
range, bandwidth, latency, powerCritical, lowCost,
hasWifi, hasCellular, highSecurity, highScale, outdoor, indoor
};
}
// Score all protocols
scored_protocols = protocols.map(p => scoreProtocol(p, requirements))
.sort((a, b) => b.score - a.score);
// Top recommendations
top_recommendations = scored_protocols.slice(0, 4);