Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12610 Discussions

How do Nios-II handle IP address change during the TCP/IP connection?

Altera_Forum
Honored Contributor II
3,861 Views

Dear all, 

 

I have problem with changing IP address in the FPGA board.  

 

Here is my case, let say I have a FPGA board which is connected to PC. The PC sends a command to the FPGA that asks the FPGA to change its IP address to a new given IP address. 

 

Here is my idea to handle this task : 

  1. After receiving IP changes command from PC, both FPGA and PC terminate their TCP/IP connection by close their socket. 

  2. The FPGA does the IP changes mechanism 

  3. Both FPGA and PC initiate a new TCP/IP connection like usual 

  4. The FPGA sends acknowledgement to the PC to tell that it already changes its IP address successfully. 

 

 

Up to here, what do you think guys? Is my idea correct? :confused:  

 

Now I'm facing problem with step no.2 above. To change the FPGA's IP address, what I'm thinking is in the FPGA I have to do these steps : 

  1. Terminate the previous TCP/IP connection (close the exist socket) 

  2. Assign new IP address to the FPGA (I have made a new function called 'change_ip' which is basically same as get_ip_addr function provided by altera) 

  3. Initiate new TCP/IP connection (create, bind, listen socket) 

 

 

But the result is error, I got this following error message : 

: See STDERR for expanded diagnosis translation. : Bind failed : ERRNO: : : See STDERR (FAULT_LEVEL is SYSTEM). : FAULT_LEVEL is SYSTEM. : FATAL Error, Restart required. : Locking scheduler - endless loop. 

 

I also tried to kill the previous "inet main" and "clock tick" tasks, but in the end it also ends up with the same error message. 

 

Anybody know how is the correct procedure to change FPGA's IP address? :confused: :confused:  

 

Thanks for any comments or suggestions!
0 Kudos
27 Replies
Altera_Forum
Honored Contributor II
465 Views

Hi Mcr42, 

 

how did you made the changing of the ip address within the website? 

Or did you just changed it static in your application code? 

 

Thanks, Urmel
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

I did it just static. 

 

But if you want to trigger actions through the webpage, you will find ProgFlashStub() in http.c. 

Here declare all the actions and which functions are called.
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

Ok, thank you very much! 

 

One last question: 

Where did you defined your change_ip() function? 

I tried it in Web_server.c but even when I enabled DHCP in Nichestacks Settings under System Library it couldn't find the dhc_state_init() function.
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

I have no clue why it does work for me without include, but a quick grep for dhc_state_init() gave me <bsp>\iniche\src\h\dhcpclnt.h .

0 Kudos
Altera_Forum
Honored Contributor II
465 Views

Ok, thanks. 

I got it running but with some workaround. I included the change_ip() function in network_utilities.c and made it "extern" so i can run it inside the webserver.c. Then I also added# include "dhcpclnt.h" to the network_utilities.c as well as defining the NetInfo struct. 

But there is still a warning, because "dhc_set_state" is not known. Curiously this function is defined in dhcpclnt.c and not in the header file. As I don't really need the dhcp at the moment I don't care. 

 

Just for the sake of interest. Which version of the NIOS-IDE do you use? 

I use the 9.1 SP2 of NIOS and i.e. the definition of IP4_ADDR is only in the network_utilities.c instead of webserver.h as it seems to be on your system.
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

I'm using 9.1SP2 too. 

 

But I moved the IP4_ADDR definition (among other edits), as there's no reason to keep it private to network_utilities.c.
0 Kudos
Altera_Forum
Honored Contributor II
465 Views

 

--- Quote Start ---  

Dear all, 

 

I have problem with changing IP address in the FPGA board.  

 

Here is my case, let say I have a FPGA board which is connected to PC. The PC sends a command to the FPGA that asks the FPGA to change its IP address to a new given IP address. 

 

Here is my idea to handle this task : 

  1. After receiving IP changes command from PC, both FPGA and PC terminate their TCP/IP connection by close their socket. 

  2. The FPGA does the IP changes mechanism 

  3. Both FPGA and PC initiate a new TCP/IP connection like usual 

  4. The FPGA sends acknowledgement to the PC to tell that it already changes its IP address successfully. 

 

 

Up to here, what do you think guys? Is my idea correct? :confused:  

 

Now I'm facing problem with step no.2 above. To change the FPGA's IP address, what I'm thinking is in the FPGA I have to do these steps : 

  1. Terminate the previous TCP/IP connection (close the exist socket) 

  2. Assign new IP address to the FPGA (I have made a new function called 'change_ip' which is basically same as get_ip_addr function provided by altera) 

  3. Initiate new TCP/IP connection (create, bind, listen socket) 

 

 

But the result is error, I got this following error message : 

: See STDERR for expanded diagnosis translation. : Bind failed : ERRNO: : : See STDERR (FAULT_LEVEL is SYSTEM). : FAULT_LEVEL is SYSTEM. : FATAL Error, Restart required. : Locking scheduler - endless loop. 

 

I also tried to kill the previous "inet main" and "clock tick" tasks, but in the end it also ends up with the same error message. 

 

Anybody know how is the correct procedure to change FPGA's IP address? :confused: :confused:  

 

Thanks for any comments or suggestions! 

--- Quote End ---  

 

 

Hi, 

I am a new in altera. I want to create double socket servers in simple socket example. For that i have changed the SOPC builder and created one more ethernet port. I have also get the different IP addresses when the DHCP enabled. I can also access the ethernet port through telnet one by one as simple socket server.c has only one socket. Now I am trying to fix the socket address. suppose the socket address is 192.168.1.5 for et1 , i can access the et1 through telnet, but when i change the socket address from 192.168.1.6 for et1, i get the same above error. socket is failed to bind. 

 

code: 

addr.sin_family = AF_INET; 

addr.sin_port = htons(SSS_PORT); 

addr.sin_addr.s_addr = inet_addr("192.168.1.6"); 

 

err: 

[Network]: See STDERR for expanded diagnosis translation. 

[Network]: [sc_task] Bind failed 

[Network]: ERRNO: :  

 

[Network]: See STDERR (FAULT_LEVEL is SYSTEM). 

[Network]: FAULT_LEVEL is SYSTEM. 

[Network]: FATAL Error, Restart required. 

[Network]: Locking scheduler - endless loop. 

 

Thanks for any suggestions!
0 Kudos
Reply