Simulatore 07 - IPv6 FLSM Fixed Length | Prof. Giagnotti SIM-06 VLSM Variable Length Subnet Mask - Simulatore Subnetting Ottimizzato | Lab Reti
PROF GIAGNOTTI · TORNA A → · GUIDE
🔧 SIMULATORE 07 - IPv6 FLSM

IPv6 FLSM: Subnetting a lunghezza fissa su 128 bit

Simulatore interattivo per dividere una rete IPv6 in sottoreti uguali. BigInt, notazione compressa :: e calcolo prefisso senza broadcast.

Prof. Andrea Giagnotti · Corso Reti · Modulo Subnetting Avanzato
⏱ 45 min 📶 IPv6 🎯 FLSM 🧮 BigInt 🔬 Laboratorio 🔗 Collegamento alla teoria

Obiettivi di apprendimento

1Comprendere IPv6: 128 bit, 8 hextet, compressione :: e perché non esiste broadcast.
2Padroneggiare conversione BigInt: da stringa IPv6 a intero a 128 bit e viceversa con zero-compression.
3Calcolare FLSM IPv6: newPrefix = prefix + ceil(log2(n)), subnetSize = 2^(128-newPrefix).
4Interpretare range: Subnet ID + range indirizzi, differenza con IPv4 (no rete/broadcast sottratti).
5Usare il simulatore: generare tabelle pronte per relazione con 2001:db8::/64 → 4×/66.

Indice — 7 sezioni

  1. Cos'è il subnetting IPv6 FLSM — definizione, 128 bit, spazio immenso
  2. Come funziona — BigInt, ::, formula, confronto IPv4 vs IPv6
  3. Simulatore IPv6 FLSM Interattivo — id ipv6FlsmSim, live JS
  4. Esempio pratico guidato — 2001:db8::/64 in 4 subnet /66
  5. Errori comuni — parsing ::, overflow prefisso, off-by-one
  6. Verifica / Esercizio — attività di laboratorio
  7. Riepilogo — takeaways

1. Cos'è il subnetting IPv6 FLSM

Definizione operativa

FLSM IPv6 = dividi una rete madre /prefix in n sottoreti uguali tutte con stesso newPrefix. Non si sottraggono broadcast/rete: ogni indirizzo è host utilizzabile, salvo riservati (Subnet-Router anycast). Spazio totale mai esauribile: /64 standard LAN contiene 2^64 ≈ 1.8e19 indirizzi.

IPv6 usa 128 bit rappresentati come 8 gruppi esadecimali da 16 bit: 2001:0db8:0000:0000:0000:0000:0000:0001. La compressione :: sostituisce una sola sequenza contigua di gruppi zero con :: → 2001:db8::1. Regola: una sola :: per indirizzo, longest run.

Perché fare FLSM in IPv6? Anche con spazio enorme, l'enterprise divide 2001:db8:abcd::/48 in /64 per VLAN, o un /64 ISP in 4×/66 per sedi uguali. Stessa logica IPv4, aritmetica diversa: tutto con BigInt perché JS Number arriva solo a 2^53.

👨‍🏫 Nota del docente

In IPv6 non esiste il broadcast L2 mappato come 255.255.255.255. Si usa multicast ff02::1. Quindi il concetto di "indirizzi utilizzabili = 2^(host)-2" sparisce. In FLSM IPv6Subnet size è semplicemente 2^(128-newPrefix). Non sottrarre 2!

2. Come funziona — dal testo al BigInt

① Parse ::
Split su "::" → left + right, riempi zeri fino a 8 gruppi. Ogni h = parseInt(h,16) → BigInt. Acc = (acc << 16n) + BigInt(h)
② Calcolo prefisso
bitsNeeded = ceil(log2(numSubnets)). newPrefix = prefix + bitsNeeded. Es. 4 subnet → 2 bit → /64→/66. subnetSize = 1n << (128-newPrefix)
③ Iterazione
base = ipv6ToBigInt(ip) & mask(prefix). Per i=0..n-1: subnetBase = base + subnetSize*i, subnetEnd = subnetBase + subnetSize -1n → bigIntToIPv6()
ConcettoIPv4 FLSMIPv6 FLSM
Bit totali32128
ConversioneNumber & shift 8 bitBigInt & shift 16 bit (hextet)
Notazione compattanon esiste:: zero-compression, una sola volta
Formula prefissonewPrefix = prefix + ceil(log2 n)Identica! Ma su 128 bit
Dimensione subnet2^(32-newPrefix) –2 host2^(128-newPrefix) tutti usabili
BroadcastSì, ultimo addrNo, multicast ff02::1
Esempio tipico192.168.0.0/24 → 4×/262001:db8::/64 → 4×/66 → 4.6e18 addr ciascuna
2001:db8::/64 → DIVISO IN 4 SUBNET /66 — 2 BIT RUBATI /48 SITE + /16 SUBNET ID 2b 62b INTERFACE ID subnetSize = 2^(128-66)=2^62 = 4.6×10¹⁸ addr/subnet — no -2!
JAVASCRIPT · Core BigInt IPv6 (escaping < >)
function ipv6ToBigInt(ip){ const parts = ip.split("::"); let left = (parts[0] ? parts[0].split(":") : []).filter(Boolean); let right = (parts[1] ? parts[1].split(":") : []).filter(Boolean); while(left.length + right.length < 8) left.push("0"); const full = left.concat(right); return full.reduce((acc,p) => (acc << 16n) + BigInt(parseInt(p,16)), 0n); } function bigIntToIPv6(num){ let parts=[]; for(let i=0;i<8;i++) parts.push(Number((num >> BigInt(16*(7-i))) & 0xffffn).toString(16)); // longest zero run -> :: let best=-1, bestLen=0, cur=-1, curLen=0; parts.forEach((p,i)=>{ if(p==="0"){ if(cur===-1){cur=i;curLen=1;} else curLen++; } else { if(curLen>bestLen){best=cur;bestLen=curLen;} cur=-1;curLen=0; } }); if(curLen>bestLen){best=cur;bestLen=curLen;} if(bestLen>1){ parts.splice(best,bestLen,""); if(best===0) parts.unshift(""); if(best+bestLen===8) parts.push(""); } return parts.join(":"); } const bitsNeeded = Math.ceil(Math.log2(numSubnets)); // es. 4 -> 2 const newPrefix = prefix + bitsNeeded; // 64+2=66 const subnetSize = 1n << BigInt(128 - newPrefix); // 2^62 // subnetBase = base + subnetSize * BigInt(i)

3. Simulatore Interattivo IPv6 FLSM

Inserisci indirizzo con o senza ::, prefisso iniziale e numero sottoreti. Il tool allinea alla rete, calcola con BigInt e genera tabella resultTable.

Simulatore IPv6 FLSM — id: ipv6FlsmSim
💡 Come leggere l'output

Subnet ID = primo indirizzo della subnet con nuovo prefisso. Range = da Subnet ID a Subnet ID + subnetSize -1. A differenza di IPv4, IPv6 non utilizza un indirizzo di broadcast e non si applica la tradizionale sottrazione di network e broadcast address usata nel calcolo degli host IPv4.. Dimensione = 2^(128-newPrefix) in notazione decimale ed esponenziale. Copia la riga per la relazione.

4. Esempio pratico guidato

Obiettivo: dividere 2001:db8::/64 in 4 subnet uguali.

Calcolo manuale

Step 1: n=4 → bitsNeeded = ceil(log2 4)=2. Step 2: newPrefix=64+2=66. Step 3: subnetSize=1<<(128-66)=2^62 = 4611686018427387904 addr. Step 4: base = 2001:db8:: = 2001:0db8:0000:0000::. Mask /64 → base allineata. Subnet: 0: 2001:db8::/66 (range :: — ::3fff:ffff:ffff:ffff), 1: 2001:db8:0:0:4000::/66 ... fino a 3: 2001:db8:0:0:c000::/66. In notazione compressa il simulatore mostra 2001:db8::, 2001:db8::4000:0:0:0 etc. a seconda della compressione ::.

OUTPUT ATTESO · 2001:db8::/64 → 4×/66
#0 Subnet ID: 2001:db8:: /66 Range: 2001:db8:: — 2001:db8::3fff:ffff:ffff:ffff Size: 2^62 #1 Subnet ID: 2001:db8::4000:0:0:0 /66 Range: 2001:db8::4000:0:0:0 — 2001:db8::7fff:ffff:ffff:ffff #2 Subnet ID: 2001:db8::8000:0:0:0 /66 Range: ...8000 — ...bfff #3 Subnet ID: 2001:db8::c000:0:0:0 /66 Range: ...c000 — ...ffff:ffff:ffff:ffff Nota: rappresentazione compatta può variare (es. 2001:db8:0:0:4000::) a seconda di bigIntToIPv6 :: compression.

5. Errori comuni

⚠️ 1. Doppio :: o sintassi hextet > ffff

Valido: 2001:db8::1, ::1, 2001:db8:0:0:0:0:0:1. Non valido: 2001::db8::1 (due ::), 2001:db8:gggg:: (g non hex), 9 gruppi. Il simulatore con filter(Boolean) e controlli alert blocca.

⚠️ 2. Prefisso >128 o bitsNeeded overflow

Se prefix=120 e chiedi 32 subnet → bitsNeeded=5 → newPrefix=125 OK. Ma prefix=120 + 1024 subnet → bitsNeeded=10 → newPrefix=130 >128 → errore "non compatibile". Formula limite: newPrefix ≤128, quindi max subnet = 2^(128-prefix).

⚠️ 3. Usare Number invece di BigInt

Number.MAX_SAFE_INTEGER = 2^53-1, IPv6 richiede 128 bit → devi usare 0n, 16n, << BigInt, & 0xffffn. Se usi parseInt senza BigInt perda precisione e range sbagliato. Il simulatore usa BigInt ovunque.

⚠️ 4. Sottrarre broadcast come in IPv4

In IPv6 FLSM non sottrarre 2! Range = subnetSize intero. L'unico indirizzo riservato in ogni /64 è il Subnet-Router anycast (ultimo 0), ma non si sottrae per conteggio host didattico.

6. Verifica / Esercizio pratico

🔬 Attività — Lab IPv6 FLSM

Usa il simulatore sopra con questi 3 casi e consegna tabella:

  1. Caso base: 2001:db8:abcd::/48 in 256 subnet → qual è newPrefix? (risposta attesa /56 — standard site). Quanto vale subnetSize?
  2. ISP → Customer: 2001:db8::/32 in 16 sedi → newPrefix? Range prima e ultima subnet?
  3. Edge: ::/0 è valido? Prova ::1/128 in 2 subnet → cosa succede? Perché newPrefix 129 >128 è bloccato?
✅ Soluzione ragionata (spoiler)

1. 256 =2^8 → bits=8 → newPrefix 48+8=56 → size 2^(72)=4.7e21. Ogni subnet è un /56 assegnabile a VLAN/cliente. 2. 16=2^4 → /36 → size 2^92 enorme. 3. /128 è un singolo host, non divisibile: bitsNeeded 1 → newPrefix 129 >128 → alert incompatibile. Coerente: un /128 non si subnetta.

✓IPv6: 128 bit, 8 hextet, :: comprimere una sola sequenza zeri più lunga.
✓BigInt: unica via JS precisa — ipv6ToBigInt con <<16n, bigIntToIPv6 con >> e & 0xffffn + compressione.
✓FLSM: newPrefix = prefix + ceil(log2(n)), subnetSize = 2^(128-newPrefix), base allineata via AND mask.
✓No broadcast: range = [subnetBase, subnetBase+size-1] tutto usabile, multicast ff02::1 per all-nodes.
✓Esempio: 2001:db8::/64 → 4×/66 → 2 bit extra → 4.6e18 addr per /66, zero spreco.