Hello Everyone,
Can i get a example code or sample code on the TCP server using the CMSIS network library
Install MDK-ARM V5.21a and open the PackInstaller to access all of the example projects provided. You can find matching projects for i.e. the STM32F400 Eval board.
Helpful links:
MDK-ARM V5.21a download: http://www2.keil.com/mdk5
PackInstaller: www2.keil.com/.../
Creating a Network Application: www.keil.com/.../network_create_app.html
TCP Networking Suite Examples: http://www.keil.com/rl-arm/rl-tcpnet_examples.asp
Hello R. Kopsch,
i have went through the example code for Creating a Network Application: www.keil.com/.../network_create_app.html.
but it is not able to assign the IP address which was set by me in the variable const char ip_addr[] = { "192.168.0.150" }.
This not a very detailed reply. However, I assume that you have left enabled DHCP, resulting in the fact that your settings may get overwritten.
FYI - the IP address is a variable in Network library - it is either set by DHCP or manually by calling netETH_SetOption(). Both options change the IP address. However if you did that before DHCP has completed (because you've left DHCP enabled in the configuration), your changes get overwritten later, when DHCP has completed.
Thank you for your response.
sorry for the previous replied which had very short explanation.
I'm working on the LPC1837 controller which is based on the ARM cortex-M3. this board is customized one. i need to make my hardware work as router. it consists of one Ethernet port and one USB port. when the USB is connected to PC. my hardware has to assign a IP address to the PC and share the network with PC. I'm using the CMSIS driver to develop the application.
Now coming to problem i'm facing.
i configure my hardware to USB to CDC class and NCM sub class , to make use of Ethernet over USB . This is working fine, but my hardware is acting as Client and PC as server.
i need my hardware to work as server and PC as client so that i can assign IP according to my wish.
so i realized that my hardware should be configure as DHCP server. then i configure my hardware to support the network library.
To make hardware work as router what are the steps i need to follow.
can you please explain it clearly with an example it would be great help.
one more thing i didn't got the API netETH_SetOption() any of the files in the network library. can i know which version of the CMSIS network library you are referring to ?
I'm sorry - it is time consuming to detail here at the forum.
We recommend to refer to the corresponding documentation, starting at: http://www.keil.com/pack/doc/mw/Network/html/ as well as to all the example projects offered at the PackInstaller.
Actually i have went through these links, i'm observing that the IP address is not getting the assigned as set. so i need the clarification whether the CMSIS network library is fully tested one (bug free) or not.
because i used DHCP server implementation by making the DHCP enable and followed the steps mention in the link. this didn't work as mentioned.
www.keil.com/.../network_create_app.html
You seem to mix and match information a lot in your posts, making it almost impossible to understand what you want to say.
- In one post, you talk about the need for having a DHCP server. - In one post, you talk about issues setting a fixed IP. - In your latest post, you talk about using a DHCP client while suddenly talking about a DHCP server again.
You talk about "Because i used DHCP server implementation by making the DHCP enable" while linking to a page that has an enable flag for DHCP client.
Your "this didn't work as mentioned" should probably be rewritten as "this didn't work as I incorrectly assumed it should work."
No library of any significant size is bug free. And "fully tested" is also quite problematic since the earth can't supply the electric current to do a full test of many significantly large programs/libraries.
But don't start to assume you suffer from bugs in the library, until you have managed to understand what the library is actually intended to do.
Hello Per Westermark,
Thanks for correcting me.
Can i know how you implemented DHCP server.
Can i know which version of the network library are referring to ?
To be a little bit rude: It would help if you decide to read the answers you receive.
See this thread (your own - related specifically to the need for a DHCP server): http://www.keil.com/forum/61808/
The answer you received from Keil was: "Network library does not support a DHCP server. You will have to implement the service on your own."
After having received this answer, you directly jumped to a completely different question - not related to DHCP server but suddenly to how to set a fixed IP on your side (which the networking suit can do):
Hi Franc Urbanc, Thank you for replying, Network library will not support DHCP server implementation correct. whether is it possible to fixed the one IP address permanently to the board(evaluation board) using network library ?"
You further wrote:
you told that Network library will not Support the DHCP server implementation. 1. can i know when the new patch or pack of network library with the working DHCP server implementation will be release ?
Which would imply that you think Franc Urbanc said there is a DHCP server - but broken - after which you wanted to know when it would be fixed.
So you once more got the answer:
Unfortunatelly DHCP server and packet router are not supported in Network library.
Nothing there, indicating that Keil sees it as a prioritized task to add a DHCP server - the people who do know how to write a router would normally have the skills to write a DHCP server. And the rest of Keil's customers do not need a DHCP server, since the huge majority of embedded devices have an interface to set a fixed IP or expects the network to supply the DHCP server.
So in the end, it comes down to this: Do you have the skills to write a DHCP server? And if you implement a router - do you have the skills to look at port forwarding, network address translations etc that would be standard functionality of a router. Remember that your device isn't just tunneling all data - you claimed that the PC behind the router should share the same connection as your embedded program used. So you need to have two external IP, or look at protocols and ports, VLAN tagging etc to decide what data that should be forwarded to the PC and what should be handled by the embedded application.
How I implemented a DHCP server using the Keil networking suite? I have never had a reason to use the Keil networking suite to implement any DHCP server. When I need router functionality, I go all the way to Linux-based solutions. Besides a DHCP server, I then also get iptables/nftables, QoS, IPsec, easy remote, modular, firmware updates, a web server that can run PHP, ...
Thank you for your detailed response.
Actually for the first time i'm working on the router development, so i don't have any idea about how to develop a router code.
i think before developing the code, i need learn about how the network protocol works. how IP addresses are assigned, what frames has to sent first to request the other device to connect. etc..
There are lots of documentation about the DHCP protocol on the net. And there is also a number of DHCP servers available with reasonably licensed source code available.
So the information needed to implement a DHCP server is available - the challenge is to decide what functionality the server needs to implement and what simplifications that can be acceptable. For example do you support just a single PC or can the user make use of a switch and expect to get IP numbers to 100 different units.
Hi Per Westermark,
The functionality of the server needs to assign a IP address to the client which is given by me, for a period of 1 day and i would like to support only one PC.
Can you share the information about this. It would be a great help.
can i know the steps involved from the scratch to develop or if you can share your implement on this.
Here's something i knocked up a few years ago as a simple test:
#!/usr/bin/env python import socket,traceback host = '192.168.1.111' port = 67 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) s.bind((host, port)) while 1: try: message, address = s.recvfrom(8192) print("DHCP Request detected") except (KeyboardInterrupt, SystemExit): raise
With a little work, this could become a useful DHCP server. I'll let you figure out how.
"Can you share the information about this. It would be a great help."
Maybe surprise us and spend a bit of own time on the project? I would not earn any money from spending time supplying you with a DHCP server.
If this is a school project, then you are expected to learn.
If this is a hobby project, then the primary reasons would be because you are interested and want to learn.
If this is a commercial project, they you get paid to do this work.