WiFi communication enables devices to connect wirelessly, facilitating seamless data exchange and internet access. It operates within the framework of the TCP/IP model, which governs how data is transmitted over networks.
Here's a limited overview of the essential concepts you'll need to understand to get two ESP32 devices communicating with each other:
-
TCP/IP Protocol Suite: The TCP/IP protocol suite consists of several layers, including the application layer, transport layer, internet layer (which includes the network layer), and link layer. Each layer plays a specific role in ensuring reliable and efficient communication.
-
Ports: Ports are virtual endpoints within a device enabling communication between different applications or services. They are identified by numerical values ranging from 0 to 65535, with certain well-known ports reserved for specific services.
-
Sockets: Sockets provide an interface for communication between two processes running on different devices over a network. They enable applications to send and receive data using standard networking protocols, identified by an IP address and a port number.
-
Network Layer: The network layer, part of the TCP/IP model, is responsible for routing and forwarding data packets between devices. It uses logical addressing (such as IP addresses) to identify devices on a network and determines the best path for data transmission.
-
IP Addresses: IP addresses are unique numerical identifiers assigned to devices on a network, facilitating communication. IPv4 (32-bit) and IPv6 (128-bit) are the two types of IP addresses commonly used.
-
Routing: Routing determines the best path for data packets to travel from the source to the destination across a network. Routers facilitate this process by forwarding packets based on network addresses, using routing tables to make decisions.
-
DNS (Domain Name System): DNS translates domain names (e.g., www.example.com) into IP addresses, enabling users to access resources using human-readable names. DNS servers maintain databases of domain names and their corresponding IP addresses.
-
DHCP (Dynamic Host Configuration Protocol): DHCP automatically assigns IP addresses and other network configuration parameters to devices on a network, simplifying network administration. DHCP servers manage the allocation process, assigning unique IP addresses and renewing leases periodically.
To establish communication between two ESP32 devices, you configure them with compatible network settings (so that they see each other, which means there exist a route for the packets to go from one to the other), implement socket-based communication using TCP/IP protocols, and ensure that the necessary ports are open for data exchange.