Skip to content

hnkr/lwip_contrib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Running LwIP TCP/IP Stack on Ubuntu

  • To develop 'target' application on host

Requirements

  • Ubuntu OS (on account of using TAP interface)
  • gcc

Build & Run

Get in lwip_contrib/contrib/ports/unix/minimal directory.

  • Build:
    • make
  • Run:
    • sudo ./echop

Working Principle

When it starts running, it will create tap1 interface and then it will link the tap1 interface to LwIP TCP/IP Stack.
Thanks to this 'link', the end user will have the chance to run network applications on the same machine but with different IP Addresses.

  • According to your network settings, you need to change the IP Address / GW Address / Subnet mask of TCP/IP Stack by changing the parameters mentioned below (in main.c):
    IP4_ADDR(&gw, 192,168,1,1);
    IP4_ADDR(&ipaddr, 192,168,1,20);
    IP4_ADDR(&netmask, 255,255,255,0);

Testing

  • You should see messages on stdout like the ones below, when it starts running successfully:

    Host at 192.168.1.20 mask 255.255.255.0 gateway 192.168.1.1
    TCP/IP initialized.
    SNMP private MIB start, detecting sensors.
    Applications started.

  • When you type "ip link" command in the terminal you should see tap1 interface up as mentioned below (Your MAC Address instead of NO):

    tap1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether NO:NO:NO:NO:NO:NO brd ff:ff:ff:ff:ff:ff

  • Communication Test:

    • To test TCP communication type the command mentioned below and then you will see the messages twice due to 'echo' server:
      nc -l 192.168.1.20(Your IP Address) 45678
    • To test UDP communication type the command mentioned below and then you will see the messages twice due to 'echo' server:
      nc -u -l 192.168.1.20(Your IP Address) 7