[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] local_ip and remote_ip

From: David Empson
Subject: Re: [lwip-users] local_ip and remote_ip
Date: Wed, 14 Apr 2010 00:54:55 +1200

Peter Nguyen wrote:
I've been inspecting some lwip code, and to get IP addresses, i've noticed two variables for storing ip addresses: local_ip, and remote_ip. I was wondering whether anyone is able to tell me the difference between the two variables.

TCP connections operate by establishing a connection between a local device and a remote device. Each end of the connection is identified by an IP address and port number, and this information is carried in each packet transmitted or received for the connection. (All packets contain two IP addresses and two port numbers.)

UDP operates on the same principle, but without maintaining connections. A UDP packet is transmitted from a local IP address and port to a remote IP address and port (or vice versa).

LWIP has a "pcb" structure which maintains information about a connection (for TCP) or a sending/receiving port (UDP). This structure includes fields to keep track of the local and remote addresses, called local_ip and remote_ip. In some code, these addresses are copied into variables called local_ip and remote_ip (and the port numbers may also be copied into local_port and remote_port). Similar variables may be used in places where packets are being processed without reference to a pcb.

In general, local_ip is the address of LWIP (or one of LWIP's addresses, if it has multiple network interfaces), and remote_ip is the address of the other device involved in the same TCP connection or for a particular UDP packet.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]