Main Site Documentation

Cerberus FTP Server


#1

Hello all,

TLDR version: My Cerberus FTP server hangs every once in a while. Any help would be appreciated!

A couple weeks ago I started looking into FTP in hopes of getting my Cerberus board to act like a client, log into a remote server, save a file, and log out. (You can see my original link here.) That is still my final goal, however, I realized I know very little about FTP, networking in NETMF, or the ethernet side of things on the Cerberus. So I took a step back and am now trying to implement an FTP server on the Cerb, which has been done before and seems like a better starting point for me.

I have implemented the FTP server using a semi-modified version of this code. As of now I can use the FTP client that comes native with Windows 7 (from command line) to log into my Cerberus using a static IP (USER, PASS), get a list of files (NLST), upload and download files (STOR, RETR), and log out (QUIT). (I’m using the built in Windows FTP client because other clients are too advanced and use commands that are yet to be implemented in the code such as LIST and TYPE I). This is all I really want from the server and if it worked reliably I could use this as a workaround for getting files from the Cerb to a remote computer.

However, it does not seem to always work. This happens mostly during a transfer of a large (~1MB) file, but happens less frequently on many of the other commands as well (USER, PASS, NLST). I’m assuming this is because a single transfer of a large file contains many more actual packets being transferred.

I have been trying to use WireShark to debug and understand what is going wrong. I have several examples, but I will try to attach the ones that are shorter to start with as to not scare anyone away with walls of TCP packets. I’ve attached a successful connect/disconnect packet history (00_basicConnectDisconnect) as well as one which was unsuccessful and ‘froze’ after the USER command was issued (01_USER_unsuccessful). (Images are all I can upload I guess.)

Note that I’m using a Cerberus main board, ethernet firmware, static IP, connected through our local network. IP for Cerberus is 192.168.1.250 and IP for my local PC is 192.168.1.250. I am still using the NETMF 4.2 versions of everything as well.

Any help here would be great!

Sivat


#2

This https://www.ghielectronics.com/community/codeshare/entry/836 is a modified version of the NETMF framework FTP server.
It runs fine on a G120 in 24/7 industrial environment.
There I use mostly the Virtual in memory file system I’ve created for the FTP, because it’s part of an file based command protocol.
By this I can not tell you if accessing the file system (like SD card) is also that stable.


#3

Thanks for the link Reinhard.

I’ve taken a look at that code as well, but I get similar problems. I’m starting to wonder if it has to do with the way I’m using my Cerberus with the ENC28 module. I found this post from last year and it got me thinking about where the problem arises.

When using the Stable FTP, my code differs only in the initialization schemes in that I am not using premium libraries. Note though that I am able to connect (using the Stable FTP as well) but I get hung up at times. Attached is a WireShark transaction using the Stable FTP which got hung up on the NLST command. Note that even though the last line was 226 Listing Complete, the Windows FTP client had already timed out by then.

Thanks,

Sivat

P.S. Is there a way to attach text files? Posting them in the message gets long and I can’t always fit everything in WireShark in a screenshot. Also, when using the code tags, my code seems double spaced, making it a bit long. Any way to use single spaces? Thanks!


#4

I had also meant to ask what FTP client you use? The server and client seem to be talking, but something is getting hung up somewhere, so maybe the Windows client isn’t good enough or I need to set some sort of longer wait time in my configurations.


#5

Do you run your Cerberus with VS debugger attached?
At least with G120 there is a problem that the debugger stops execution of the program when the program gets more complex.
I would consider the FTP server as complex already.

See here:
https://www.ghielectronics.com/community/forum/topic?id=16304

To test if this is the case just run your device without debugger (just reset it).

As FTP Client I used WindowsExplorer (does extensive caching, which is not always good) or Filezilla.

Edit: If you find out that you also have the Debugger stop issue, please vote on codeplex:


#6

Most of my debugging is done without running in Debug mode. I usually reset the Cerberus using the on-board reset button and clear my WireShark logs before a test.

How large are the files you transfer using the virtual memory file system? Do you use it to access files stored only in RAM? Are you able to access files saved/created over multiple reboots (log files for example)?


#7

Hi,
when I worked on my Bluetooth file Transfer Project initially I saw that the transmisson of large files ( 1 - 3 MByte) occasionally crashed. I found out that this was a problem of reading and writing to the SD-Card. If you simulate SD-Card reading and writing in your ftp-Server with “Dummy Data” and it does not Crash the reason must be the SD-Card.
Do you use the normal SD-Card module or the Micro SD-Card Module? Use a short gadgeteer cable to connect the SD-Card.
Cheers
Roland


#8

Hey Ronald,

Thank you for your input. I use the micro SD card module. I have been tracking errors down in the code (after the last post I realized I had been trying to debug TCP packets for long enough and went back to debugging the code). I’ve noticed a handled exception is thrown when doing something with the file data. That does seem to point towards the SD card side of things.

Thanks. I’ll post what I find here.

Sivat


#9

On a Cerbuino Bee I had no problems with a SanDisc 1 GB Micro SD

With a large SD-Card Module after I soldered a 6.8 uF Tantal capacitor between GND and VCC directly on the SD-Card module it worked reliable.
(But this is an observation which yet has not been confirmed by somebody else)


#10

the larger files have several hundred kByte.
As you might have guessed, the in memory files will not survive a reboot.
But I heard the flash module should be quite fast at writing (SPI speed I guess).
The SD card is not really performant. May be you could tweak the SD clock as discussed in several threads lately.
In my case id discontinued writing log files to SD, because nothing worked anymore when I did. Sending the same amount of log messages over Ethernet (ENC28) made no problems.


#11

So for now I am just using the Stable FTP Server code. I believe I get less hang ups/errors using it. I have found that my Cerberus gets a Failed Allocation error during the stream.Read() call when reading from the SD card. This was simple to fix in that I just catch the thrown exception and retry the read. So far it works well.

Another thing to note is that I am getting almost no system hangs anymore. I am not sure why this is. I haven’t changed the code or the hardware setup, but at the moment I am able to reliably log in, download files, and log out from my Cerberus.

I don’t really like problems that go away by themselves, but for now I just wanted to post an update. Maybe the problem will come back and we can have something to talk about ;D

Thanks for everyone’s help and input.

Sivat