diff --git a/src/lib/components/CIDRConverter.svelte b/src/lib/components/CIDRConverter.svelte deleted file mode 100644 index 55e3560..0000000 --- a/src/lib/components/CIDRConverter.svelte +++ /dev/null @@ -1,613 +0,0 @@ - - -
-
-

CIDR ↔ Subnet Mask Converter

-

Convert between CIDR notation and subnet mask formats.

-
- - -
- - -
- - - {#if selectedTab === 'cidr-to-mask'} -
- -
- - - -
- -
- 0 - 8 - 16 - 24 - 32 -
-
-
- - -
-
- Subnet Mask - - {maskValue} - -
-
-
- {/if} - - - {#if selectedTab === 'mask-to-cidr'} -
- -
- - -
- - -
-
- CIDR Notation - - /{cidrValue} - -
-
-
- {/if} - - -
-

Subnet Information

-
- -
- Network Bits - {cidrValue} -
-
- -
- Host Bits - {32 - cidrValue} -
-
- -
- Usable Hosts - - {(subnetInfo.hosts).toLocaleString()} - -
-
-
-
- - -
-

Common Subnets

-
- {#each COMMON_SUBNETS as subnet} - - - - {/each} -
-
- - -
-

Understanding CIDR and Subnet Masks

- -
-
-

CIDR Notation

-

CIDR (Classless Inter-Domain Routing) uses a slash followed by a number (e.g., /24) to indicate how many bits are used for the network portion of an IP address.

-
- -
-

Subnet Mask

-

A 32-bit number that masks an IP address to divide it into network and host portions. Written in dotted decimal notation (e.g., 255.255.255.0).

-
- -
-

Network Bits

-

The leftmost bits in an IP address that identify the network. More network bits mean smaller subnets with fewer available host addresses.

-
- -
-

Host Bits

-

The remaining bits used for host addresses within the network. More host bits allow for more devices but fewer possible subnets.

-
-
- -
-

Common Conversions

-
-
- /24 - ↔ - 255.255.255.0 - 254 hosts -
-
- /25 - ↔ - 255.255.255.128 - 126 hosts -
-
- /26 - ↔ - 255.255.255.192 - 62 hosts -
-
- /30 - ↔ - 255.255.255.252 - 2 hosts -
-
-
- -
-

🔧 Usage Tips

-
    -
  • Smaller CIDR = Bigger Network: /16 has more hosts than /24
  • -
  • Binary Thinking: Each bit doubles or halves the number of addresses
  • -
  • /30 for Links: Perfect for point-to-point connections (only 2 usable IPs)
  • -
  • Planning: Start with larger subnets and subdivide as needed
  • -
-
-
-
- - diff --git a/src/lib/components/CIDRInput.svelte b/src/lib/components/CIDRInput.svelte index cbb5f37..000eb08 100644 --- a/src/lib/components/CIDRInput.svelte +++ b/src/lib/components/CIDRInput.svelte @@ -195,4 +195,4 @@ } } } - \ No newline at end of file + diff --git a/src/lib/components/CommonSubnetsReference.svelte b/src/lib/components/CommonSubnetsReference.svelte new file mode 100644 index 0000000..cb955dc --- /dev/null +++ b/src/lib/components/CommonSubnetsReference.svelte @@ -0,0 +1,87 @@ + + +
+
+

Common Subnets Reference

+

Frequently used subnet configurations with CIDR notation, masks, and host counts.

+
+ + +
+
+ CIDR + Subnet Mask + Hosts + Usage +
+ + {#each COMMON_SUBNETS as subnet} + +
+ + /{subnet.cidr} + + + {subnet.mask} + + + {subnet.hosts.toLocaleString()} + + + {#if subnet.cidr === 8} + Large ISPs + {:else if subnet.cidr === 16} + Universities + {:else if subnet.cidr === 24} + Small businesses + {:else if subnet.cidr === 25} + Departments + {:else if subnet.cidr === 26} + Teams + {:else if subnet.cidr === 27} + Small offices + {:else if subnet.cidr === 28} + Workgroups + {:else if subnet.cidr === 29} + Small groups + {:else if subnet.cidr === 30} + Point-to-point + {:else} + General use + {/if} + +
+
+ {/each} +
+ + +
+

+ + Subnet Planning Guidelines +

+
+

+ Choosing the right subnet size is crucial for efficient network design. + Consider future growth, address conservation, and security requirements when planning subnets. +

+
+

Planning Considerations

+
    +
  • Future Growth: Always plan for 2-3x current requirements
  • +
  • VLSM: Use Variable Length Subnet Masking for efficient allocation
  • +
  • Security: Separate different network segments and services
  • +
  • Point-to-Point Links: Use /30 or /31 for WAN connections
  • +
+
+
+
+
+ diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte new file mode 100644 index 0000000..fc813ba --- /dev/null +++ b/src/lib/components/Footer.svelte @@ -0,0 +1,23 @@ + diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte new file mode 100644 index 0000000..0b6352f --- /dev/null +++ b/src/lib/components/Header.svelte @@ -0,0 +1,68 @@ + + + + + + +
+
+
+ + +
+ + + +
+
+
+
diff --git a/src/lib/components/IPConverter.svelte b/src/lib/components/IPConverter.svelte index f84327c..3919413 100644 --- a/src/lib/components/IPConverter.svelte +++ b/src/lib/components/IPConverter.svelte @@ -296,6 +296,9 @@ .class-info { text-align: center; + display: flex; + flex-direction: column; + align-items: center; } .class-value { diff --git a/src/lib/components/InfoPanel.svelte b/src/lib/components/InfoPanel.svelte deleted file mode 100644 index 971c232..0000000 --- a/src/lib/components/InfoPanel.svelte +++ /dev/null @@ -1,436 +0,0 @@ - - -
-
-

Network Reference

-

Essential networking information and constants for IP address planning.

-
- - -
- - - -
- - - {#if selectedCategory === 'classes'} -
- {#each Object.entries(NETWORK_CLASSES) as [className, classInfo]} - -
-
-
-
- {className} -
-
-

Class {className}

- - {classInfo.defaultMask} (/{classInfo.cidr}) - -
-
- - {classInfo.range.split(' - ')[0]} - {classInfo.range.split(' - ')[1]} - -
- -

- {classInfo.description} -

- -

- Typical Usage: {classInfo.usage} -

-
-
- {/each} -
- {/if} - - - {#if selectedCategory === 'reserved'} -
- {#each Object.entries(RESERVED_RANGES) as [rangeName, rangeInfo]} - -
-
-
-

- {rangeInfo.range} -

- - {rangeInfo.description} - -
- - {rangeInfo.rfc} - -
- - - {#if rangeName.includes('PRIVATE')} -
- Private Network: Not routed on the public Internet -
- {/if} -
-
- {/each} -
- {/if} - - - {#if selectedCategory === 'subnets'} -
-
- CIDR - Subnet Mask - Hosts - Usage -
- - {#each COMMON_SUBNETS as subnet} - -
- - /{subnet.cidr} - - - {subnet.mask} - - - {subnet.hosts.toLocaleString()} - - - {#if subnet.cidr === 8} - Large ISPs - {:else if subnet.cidr === 16} - Universities - {:else if subnet.cidr === 24} - Small businesses - {:else if subnet.cidr === 25} - Departments - {:else if subnet.cidr === 26} - Teams - {:else if subnet.cidr === 27} - Small offices - {:else if subnet.cidr === 28} - Workgroups - {:else if subnet.cidr === 29} - Small groups - {:else if subnet.cidr === 30} - Point-to-point - {:else} - General use - {/if} - -
-
- {/each} -
- {/if} - - -
-

- - - - Pro Tips -

- -
-
- - diff --git a/src/lib/components/NetworkClassesReference.svelte b/src/lib/components/NetworkClassesReference.svelte new file mode 100644 index 0000000..6b90abf --- /dev/null +++ b/src/lib/components/NetworkClassesReference.svelte @@ -0,0 +1,100 @@ + + +
+
+

Network Classes Reference

+

Traditional IP address classes and their characteristics for network planning.

+
+ + +
+ {#each Object.entries(NETWORK_CLASSES) as [className, classInfo]} + +
+
+
+
+ {className} +
+
+

Class {className}

+ + {classInfo.defaultMask} (/{classInfo.cidr}) + +
+
+ + {classInfo.range.split(' - ')[0]} - {classInfo.range.split(' - ')[1]} + +
+ +

+ {classInfo.description} +

+ +

+ Typical Usage: {classInfo.usage} +

+
+
+ {/each} +
+ + +
+

+ + Understanding Network Classes +

+
+

+ Historical Context: Network classes were the original method of IP address allocation, + now largely replaced by CIDR (Classless Inter-Domain Routing) for more efficient address utilization. +

+
    +
  • • Class A: Large networks with millions of hosts (0-127 first octet)
  • +
  • • Class B: Medium networks with thousands of hosts (128-191 first octet)
  • +
  • • Class C: Small networks with up to 254 hosts (192-223 first octet)
  • +
  • • Classes D and E are reserved for multicast and experimental use
  • +
+
+
+ + +
+

+ + Network Class Fundamentals +

+
+

+ Network classes provide a standardized way to understand IP address ranges and their intended use. + While modern networks use CIDR notation, understanding classes helps with legacy systems and network analysis. +

+
+

Class Comparison

+
+
+ Class A + 16.7M networks, 16.7M hosts each +
+
+ Class B + 65K networks, 65K hosts each +
+
+ Class C + 2M networks, 254 hosts each +
+
+
+
+
+
+ diff --git a/src/lib/components/ReservedRangesReference.svelte b/src/lib/components/ReservedRangesReference.svelte new file mode 100644 index 0000000..54cb331 --- /dev/null +++ b/src/lib/components/ReservedRangesReference.svelte @@ -0,0 +1,68 @@ + + +
+
+

Reserved IP Ranges Reference

+

Special-purpose IP address ranges defined by RFCs and their intended uses.

+
+ + +
+ {#each Object.entries(RESERVED_RANGES) as [rangeName, rangeInfo]} + +
+
+
+

+ {rangeInfo.range} +

+ + {rangeInfo.description} + +
+ + {rangeInfo.rfc} + +
+ + + {#if rangeName.includes('PRIVATE')} +
+ Private Network: Not routed on the public Internet +
+ {/if} +
+
+ {/each} +
+ + +
+

+ + Understanding Reserved IP Ranges +

+
+

+ Reserved IP ranges serve specific purposes in networking and are defined by various RFCs (Request for Comments). + Understanding these ranges is crucial for network planning and avoiding conflicts. +

+
+

Key Categories

+
    +
  • Private Networks (RFC 1918): Used for internal networks, not routed on the Internet
  • +
  • Loopback (RFC 1122): Traffic that never leaves the local machine
  • +
  • Link-Local (RFC 3927): Automatic IP configuration when DHCP is unavailable
  • +
  • Multicast (RFC 3171): One-to-many communication protocols
  • +
+
+
+
+
+ diff --git a/src/lib/components/SubHeader.svelte b/src/lib/components/SubHeader.svelte new file mode 100644 index 0000000..7553887 --- /dev/null +++ b/src/lib/components/SubHeader.svelte @@ -0,0 +1,26 @@ + + +{#if links} + +{/if} diff --git a/src/lib/constants/nav.ts b/src/lib/constants/nav.ts new file mode 100644 index 0000000..44f27a2 --- /dev/null +++ b/src/lib/constants/nav.ts @@ -0,0 +1,36 @@ +export type NavItem = { + href: string; + label: string; +}; + +export const TOP_NAV: NavItem[] = [ + { href: '/subnet-calculator', label: 'Subnet Calc' }, + { href: '/cidr-convertor', label: 'CIDR Convert' }, + { href: '/ip-address-convertor', label: 'IP Convert' }, + { href: '/ip-reference', label: 'Reference' } +]; + +// Sections that have sub-pages (drives the conditional SubHeader) +export const SUB_NAV: Record = { + '/cidr-convertor': [ + { href: '/cidr-convertor/cidr-to-subnet-mask', label: 'CIDR → Mask' }, + { href: '/cidr-convertor/subnet-mask-to-cidr', label: 'Mask → CIDR' } + ], + '/ip-reference': [ + { href: '/ip-reference/network-classes', label: 'Network Classes' }, + { href: '/ip-reference/reserved-ranges', label: 'Reserved Ranges' }, + { href: '/ip-reference/common-subnets', label: 'Common Subnets' } + ] +}; + +// Helper: is a nav item active for a given pathname? +export function isActive(pathname: string, href: string): boolean { + if (href === '/') return pathname === '/'; + return pathname === href || pathname.startsWith(href + '/'); +} + +// Helper: find the section key (e.g. '/reference') that matches a pathname +export function findSectionKey(pathname: string): string | null { + const keys = Object.keys(SUB_NAV); + return keys.find((k) => isActive(pathname, k)) ?? null; +} diff --git a/src/lib/contexts/cidr.ts b/src/lib/contexts/cidr.ts new file mode 100644 index 0000000..7cbe0d3 --- /dev/null +++ b/src/lib/contexts/cidr.ts @@ -0,0 +1,17 @@ +import type { Writable } from 'svelte/store'; + +export const CIDR_CTX = Symbol('CIDR_CTX'); + +export type SubnetInfo = { + cidr: number; + mask: string; + hosts: number; +}; + +export interface CidrContext { + cidr: Writable; + mask: Writable; + handleMaskChange: (value: string) => void; + getSubnetInfo: (cidr: number) => SubnetInfo; + COMMON_SUBNETS: Array<{ cidr: number; mask: string; hosts: number }>; +} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index f6c16e6..bd7f8b5 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,11 +4,64 @@ import '../styles/components.scss'; import favicon from '$lib/assets/favicon.svg'; + + import Header from '$lib/components/Header.svelte'; + import SubHeader from '$lib/components/SubHeader.svelte'; + import Footer from '$lib/components/Footer.svelte'; + let { children } = $props(); + + import '../styles/pages.scss'; + + let darkMode = $state(true); + + function initializeTheme() { + if (typeof window === 'undefined') return; + + const saved = localStorage.getItem('theme'); + if (saved === 'light') { + darkMode = false; + document.documentElement.classList.add('theme-light'); + } + } + + function toggleTheme() { + darkMode = !darkMode; + if (typeof window !== 'undefined') { + localStorage.setItem('theme', darkMode ? 'dark' : 'light'); + if (darkMode) { + document.documentElement.classList.remove('theme-light'); + } else { + document.documentElement.classList.add('theme-light'); + } + } + } + + $effect(() => { + initializeTheme(); + }); -{@render children?.()} + +
+ +
+ {@render children?.()} +
+