跳转至

1.0 OSI and TCP/IP

Core: Understanding Network Layering

Why Layering is Important

ConceptDescriptionBenefits
Managing ComplexityComputer networking is divided into small, manageable layersMakes complex tasks easier to understand and manage
Independent FunctionsEach layer provides well-defined, independent functionalityAllows independent improvement without changing entire stack
Service HierarchyEach layer serves the layer above and is served by layer belowCreates clear service boundaries and interfaces
Minimal Interface TrafficLayers have minimum traffic between interfacesImproves efficiency and reduces coupling
Fault IsolationProblems can be isolated to specific layersEasier troubleshooting and maintenance

Key Network Concepts

Protocols: The Rules of Communication

AspectDescription
DefinitionSet of rules governing data communication
PurposeDetermines what, how, and when data is communicated
RequirementsBoth sender and receiver must follow the protocol
ExamplesTCP/IP, HTTP, SMTP, UDP, FTP, SSH

Standards: Ensuring Interoperability

AspectDescription
PurposeAgreed-upon conventions for communication
BenefitsEnable devices from different companies to communicate
CompetitionProvide fair competition by establishing common requirements
ChallengesDifficult due to competing interests and risk of bad standards

Data Processing Flow

ProcessSenderReceiver
Header/TrailerEach layer appends its own header/trailerEach layer removes its header/trailer
Data FlowData flows down the stackData flows up the stack
InformationHeaders contain control information (addresses, sequence numbers, checksums)Headers are processed and removed

The OSI Reference Model (7 Layers)

Model Overview

AspectDetails
OrganizationISO (International Standards Organization)
Year Standardized1983
PurposeGeneric standard for understanding network interactions
FoundationBased on principles of abstraction, independent functions, and manageability

OSI Layer Structure

LayerNamePrimary FunctionKey ResponsibilitiesData Unit
7ApplicationUser services interfaceDirect services to users, interface between applications and networkData
6PresentationData format standardizationTranslation, compression, encryption/decryptionData
5SessionDialogue managementConnection establishment/closing, synchronization, mode negotiationData
4TransportEnd-to-end process deliveryPort numbers, segmentation, flow control, error control, connection managementSegments
3NetworkInternetworkingLogical addressing (IP), routing, forwarding, fragmentationPackets
2Data LinkSingle link reliabilityFraming, physical addressing (MAC), flow control, error control, access controlFrames
1PhysicalRaw bit transmissionElectrical/mechanical interfaces, voltage levels, timing, physical connectorsBits

Detailed Layer Functions

Layer 1: Physical Layer

  • Core Function: Transmit raw bit stream over physical medium
  • Key Aspects:
  • Electrical and mechanical interfaces
  • Voltage levels and timing
  • Physical connectors
  • Transmission media (copper, fiber, wireless)
  • Focus: Physical transmission only, not bit meaning
  • Core Function: Reliable transmission over single link (one hop)
  • Sub-layers: Logical Link Control (LLC) and Media Access Control (MAC)
  • Key Functions:
FunctionDescription
FramingDelimiting data into frames
Physical AddressingMAC address identification
Flow ControlThrottling frame flow between sender/receiver
Error ControlDetecting/correcting frame errors (CRC, checksums)
Access ControlManaging shared medium access (CSMA/CD, Token Ring)

Layer 3: Network Layer

  • Core Function: End-to-end packet delivery across multiple networks
  • Key Functions:
FunctionDescription
Logical AddressingIP address scheme for internetwork hosts
RoutingDetermining best path across networks
ForwardingMoving packets between router ports
Fragmentation/AssemblyHandling different MTU sizes
Packet SequencingOrder management (handled by higher layers)

Layer 4: Transport Layer

  • Core Function: Process-to-process message delivery
  • Protocol Examples: TCP (reliable, connection-oriented), UDP (unreliable, connectionless)
  • Key Functions:
FunctionDescription
Port NumbersApplication/process identification
Segmentation/ReassemblyData division and reconstruction
End-to-End Flow ControlReceiving process rate management
End-to-End Error ControlReliable delivery with retransmission
Connection ManagementTCP handshake, connection lifecycle

Layer 5: Session Layer

  • Core Function: Dialogue management between end systems
  • Key Operations:
  • Connection establishment and closing
  • Synchronization (checkpoints for recovery)
  • Communication mode negotiation (full/half duplex)

Layer 6: Presentation Layer

  • Core Function: Standard format for information transfer
  • Key Functions:
  • Data translation between different systems
  • Data compression
  • Encryption and decryption
  • Compatibility problem resolution

Layer 7: Application Layer

  • Core Function: Direct user services
  • Examples: Web browsers, email clients, file transfer programs
  • Protocol Examples: HTTP, SMTP, FTP

The TCP/IP Model (4 Layers)

Model Overview

AspectDetails
UsageWidely used and prevalent, especially for the Internet
DevelopmentDeveloped independently of the OSI model
CharacteristicsFewer layers but captures similar functionalities

TCP/IP Layer Structure

LayerNameOSI EquivalentPrimary FunctionProtocols
4ApplicationApplication + Presentation + SessionUser services and data formattingHTTP, SMTP, FTP, DNS
3TransportTransportEnd-to-end process communicationTCP, UDP
2InternetNetworkPacket delivery across networksIP, ICMP, ARP
1Network AccessData Link + PhysicalPhysical transmission and local network accessEthernet, WiFi, PPP

Layer Mapping Comparison

OSI Model (7 layers)          TCP/IP Model (4 layers)
┌─────────────────────┐       ┌─────────────────────┐
│   7. Application    │       │                     │
├─────────────────────┤       │   4. Application    │
│   6. Presentation   │  ───► │                     │
├─────────────────────┤       │                     │
│   5. Session        │       │                     │
├─────────────────────┤       ├─────────────────────┤
│   4. Transport      │  ───► │   3. Transport      │
├─────────────────────┤       ├─────────────────────┤
│   3. Network        │  ───► │   2. Internet       │
├─────────────────────┤       ├─────────────────────┤
│   2. Data Link      │       │                     │
├─────────────────────┤  ───► │ 1. Network Access   │
│   1. Physical       │       │                     │
└─────────────────────┘       └─────────────────────┘

OSI vs. TCP/IP: Comparison and Analysis

Key Differences Comparison

AspectOSI ModelTCP/IP Model
Number of Layers7 layers4 layers
StandardizationStandardized later (1983)Developed earlier, based on existing protocols
Protocol SuiteDefined model and protocol suite (less successful)Based on existing, successful protocols (TCP, IP)
ComplexityMore detailed layer separationSimpler, more practical approach
AdoptionPrimarily conceptual/educationalWidely implemented in practice

Why TCP/IP is More Prevalent

FactorExplanation
Historical AdvantageTCP/IP protocols became popular before OSI adoption
Practical ImplementationSimpler and more practical for building the Internet
Existing InfrastructureBuilt on proven, working protocols
Industry SupportEarly adoption by major technology companies

Current Relevance and Usage

ModelPrimary UseAdvantages
OSIConceptual understanding and educationGeneric standard, detailed layer separation, good for discussion
TCP/IPPractical implementation, Internet infrastructureProven protocols, simpler structure, real-world deployment

Model Selection Guidelines

ScenarioRecommended ModelReason
Network EducationOSIMore detailed layer separation aids understanding
Internet ApplicationsTCP/IPMatches actual Internet implementation
Protocol DesignEitherDepends on level of detail needed
TroubleshootingOSIBetter fault isolation with more specific layers

Alternative Layer Models: Merging and Optimization

Hypothetical 5-Layer Model Example

Instead of OSI's 7 layers, consider a simplified 5-layer approach:

LayerFunctionFormed by Merging
5Application ServicesOSI Application + Presentation + Session
4TransportOSI Transport (unchanged)
3NetworkOSI Network (unchanged)
2LinkOSI Data Link + Physical
1Physical MediumAlternative: keep separate

Layer Merging Analysis

Common Merge Scenarios

Merge OptionLayers CombinedReasoning
Upper Layer MergeApplication + Presentation + SessionSimilar focus on user services and data representation
Lower Layer MergePhysical + Data LinkBoth handle local link transmission
TCP/IP StyleMultiple combinationsProven simplification approach

Advantages vs. Disadvantages

AspectMerging LayersKeeping Separate
Simplicity✓ Fewer layers to manage✗ More complex structure
Efficiency✓ Less inter-layer overhead✗ More interface traffic
Modularity✗ Reduced independence✓ Clear separation of concerns
Fault Isolation✗ Harder to pinpoint issues✓ Easier troubleshooting
Implementation✗ More complex single layers✓ Simpler individual layers

Design Considerations

FactorFewer LayersMore Layers
Best ForSimple networks, practical implementationComplex systems, educational purposes
MaintenanceEasier overall managementBetter fault isolation
PerformancePotentially fasterMore overhead
FlexibilityLess modularHighly modular