Introduction to TCP/IP (Part 3) - Client Server Model

Source: Microchip Developer Help

Client Server Model Defined

The client-server programming model is a distributed computing architecture that segregates information users (clients) from information providers (servers).

Client

Server

Key Principle

Alternative: Peer to Peer (P2P)

In P2P architectures, two or more hosts communicate directly with each other (no client-server distinction).


Client Server Examples

Example: DHCP Client Server

image

The Dynamic Host Configuration Protocol (DHCP) is responsible for requesting and offering IP addresses.

Component Role Description
DHCP Client Requests IP Automatically requests an IP address when a network is detected
DHCP Server Provides IP Always active, ready to respond to client requests

Example: HTTP Client and Server

image

Scenario: Using an HTTP client on a PC to control home lights

  1. HTTP client runs on a home lighting control board
  2. Control board monitors a lighting control website on an Internet web server
  3. User browses to the same webpage, enters credentials
  4. User changes the webpage settings
  5. Control board checks the webpage and controls lights accordingly

Example: HTTP Client and Server in the Same Host

image

A network host can be both a client and a server simultaneously.

Example:

Example: Local Network HTTP Server

image

An HTTP server on an embedded device can directly control the device:


Internet Server vs. Local Network Server

Internet Server

image

Accessing an HTTP server on the Internet is effortless.

Architecture:

Hosting Options:

Local Network Server

image

HTTP server located on a local network (running on the embedded device itself).

Architecture:

Challenges that Internet servers don’t have:


Local Network Server Obstacles and Solutions

Obstacles

  1. Firewall - Router restricts public access to local network
  2. No website name - Remote clients must use IP address
  3. Dynamic IP address - ISP may change your IP address

Firewall image

Internet
    │
    ▼
┌─────────────────────────────┐
│  Office Router + Firewall   │  ← Firewall is HERE (inside the router)
└─────────────────────────────┘
    │
    ▼
┌─────────────────────────────┐
│  Office Network (Private)   │  ← This is BEHIND the firewall
│  - HTTP Server 192.168.1.101│
└─────────────────────────────┘

image

Solution 1: Port Forwarding

When you receive incoming traffic on port 80 (HTTP), don’t block it. Instead, forward it to the internal device at 192.168.1.101

image

Port forwarding allows Internet packets destined for a particular port to be forwarded to a specific local network IP address.

Configuration:

Note: Properly implemented and secure port forwarding is also called a “firewall pinhole

Solution 2: Website Name (Domain Name)

image

Advantages of a website name:

Domain name providers:

Solution 3: Dynamic IP Address Handling

image

Understanding Dynamic vs Static IP:

Type Description Typical Use
Dynamic IP Can change at any time Assigned by ISPs to customers
Static IP Fixed, never changes Internet routers and servers

Static IP addresses cost more from ISPs

Solution for Dynamic IP:

  1. Use website name instead of IP address to access your server
  2. Update DNS server with new IP address when it changes
  3. Some routers have this capability built-in
  4. Embedded device can periodically check its IP and update DNS if changed

DNS Service Providers:

image

These provide domain names and ability to update DNS servers when IP changes.


Learn More