Example: Simplified Local Network TCP/IP Communication

Now that we know how IP addresses are assigned and how switches and routers work, let's observe how two hosts communicate with each other on a local network.

The following steps show a simplified Transmission Control Protocol (TCP)/Internet Protocol (IP) transaction to get an IP address.

  1. Open the Web Browser and Enter the IP Address for the Development Board
  2. PC Generates and Transmits a Frame
  3. Frame is Forwarded Through the Switch
  4. Frame Arrives at the Development Board and is Forwarded to the Web Server
  5. Web Server Sends the Webpage to the PC

Assume we have an embedded network device we want to control and monitor. One way we could do this is to create a web page on the embedded device that displays the status of the embedded device. This web page could also be used to control the device.

local_comm.png

1 Open the Web Browser and Enter the IP Address for the Development Board

We will use a web browser on the PC to access a web page on the development board.

Note that both the PC and development board in this example currently have an IP address. This also means the switch has seen a frame sent from each node, so the switch’s routing table has been updated to show which MAC address is connected to each port.

We open a web browser on the PC and enter the IP address for the development board.

local_comm_step_1.png

2 PC Generates and Transmits a Frame

The PC creates a frame of data then sends it to the PHY to transmit on the local network.

This frame was initiated by the web browser when it created a message requesting to download the web page found at IP address 192.168.1.102

The source and destination IP addresses were added to the message to create a packet, then the source and destination MAC addresses were added to the packet to create the frame.

local_comm_step_2.png

This step has been simplified. It does not show the Transport Layer (TCP). It also doesn’t show the Address Resolution Protocol (ARP) process of obtaining the destination MAC address.

3 Frame is Forwarded Through the Switch

The frame arrives at the switch and it is opened to find the destination MAC address. This MAC address is found in the routing table so it sends it out to Port 0.

local_comm_step_3.png

Note that the switch only opens the frame to determine the MAC address. A switch is a layer 2 device and is only concerned with layer 2 (MAC) addresses. It doesn’t touch the packet or care what the IP address is.

4 Frame Arrives at the Development Board and is Forwarded to the Web Server

The frame arrives at the development board and the message is delivered to the web server application. Let’s look at this process in more detail:

When the frame arrives at the development board, the destination MAC address is checked to determine if it needs to pay attention to the frame. The MAC address matches its own, so it opens the frame to check the destination IP address in the packet. The development board finds the destination IP address matches its own and opens the packet to see what the message is. The development board finds that the message is for a web server. The board happens to have a web server running on it, so it sends the message to the web server application.

local_comm_step_4.png
  • If the MAC address in the frame doesn’t match the device’s MAC address, the frame will be discarded by the Data Link Layer (Layer 2).
  • If the IP address in the packet doesn’t match the device’s IP address, the packet will be discarded by the Network Layer (Layer 3).
  • If a message is sent to an application (port number) that is not running in the device it will be discarded by the Transport Layer (Layer 4).

5 Web Server Sends the Webpage to the PC

Now it’s time for the development board to send the web page. The development board generates a message containing the web page then sends the frame to the PC. Let’s look at this process in more detail:

The web server running on the development board generates a message containing the web page. The board then adds the source and destination IP addresses to create a packet and adds the source and destination MAC addresses, creating a frame. This frame is then sent to the PHY for transmission on the local network.

local_comm_step_5.png

Question:
What happens next?
Answer:

  1. The frame is received at the switch.
  2. The switch finds the frame’s destination MAC address and uses its routing table to determine what port to forward the frame to.
  3. The frame is sent to the PC
  4. The PC opens the frame and checks the destination MAC address to determine if it needs to pay attention to it.
  5. The PC opens the packet and checks the destination IP address.
  6. The PC opens the message and finds the web page (which is just an HTML file) it requested.
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.