Friday, 27 November 2020

Process of finding a file from the EXFAT filesystem

                                     I hope the reader will have the basic knowledge about the EXFAT filesystem. For finding a file from the SD card formatted with EXFAT filesystem, we need to read the file entries.   

                                     Basically there are 3 or more file entries associated with a single file. These file entries are File directory entry, Stream Extension directory entry and Filename Directory entry. Filename directory entry contains the filename and a single file can have more than one filename entry depending on the length of the filename but only can have one file and stream entry. Here I am not going into the detailed explanation of the file entries. But briefly I can say these file entries hold all the details about a file including starting cluster, file attributes, timestamp etc.

                                     Lets assume we have to find a file called "myfile" which exists in directory "mydir/myfile" and the "mydir" contains different other files. Our PWD is "mydir" and we are staring a file search then file entry read will starts from the first cluster of  "mydir". Initial process is to read the file directory entry located at the starting cluster of the "mydir". From the file directory entry we will get the secondary count value. The secondary count denotes the number of secondary directory entries(stream and filename entry) following the primary directory entry(File directory entry). 

                                     Next step is to read the stream extension directory entry and filename directory entry from the media. After reading these entries, from the filename directory entry we will extract the filename. As you know that EXFAT filesystem is case insensitive, we need to convert the filename to upcase and then compares with the required filename(already up-cased). If both filename matches we have successfully found the file we are looing for, otherwise again repeat the previous steps - reading the directory entries and comparing the filename. There are several other internal process involved during the search but in this post I am trying to give a high level point of view of the search process.


Thursday, 26 November 2020

How to make the TCP server unreachable(NO response) on the fly

                                   I would like to share one of my previous experience with TCP Client-Server testing. My use case was to test the behavior of TCP client while the server is unreachable. Before going into the details, I will briefly introduce the test setup which I used:

  • TCP Client-Server with 3-way handshake mechanism.
  • TCP Client-Server  IP version- IPv4 
  • Code to test - TCP Client 
  • Platform used - Windows 10 PC with additional ethernet adapter

                                   So now my PC has got 2 ethernet interfaces and the client will run on the Ethernet interface 1 and server will run on the Ethernet interface 4.

                                   More about the scenario, after the connection is established, client tries to send some data[PSH, ACK]to the server when the server is unreachable. The server should go to the unreachable state without sending any notification to the client. This is where the issue exists because when I tried to disconnect or disable or close the server, it will send either [RST, ACK] or [FIN, ACK]message to the client. I also tried to disable the ethernet interface where the server is running but no success. 

                                    Finally I figured out there is a simple technique to make the server unreachable without sending any notification to the client. For this go to the specific ethernet adapter where your server is running and click on the properties and uncheck the Internet Protocol Version 4(TCP/IPv4) and that's it. I hope this trick will be helpful for some one with similar test environment.


Sunday, 11 October 2020

Useful Tools for Software Developers - Part 2

                        This is the continuation of the previous post. Again I would introduce some other open source tools with I used for my previous projects

  • Active DISK EDITOR:                                                                                                                     This tool will allow you to have a detailed look into the internal structure of the filesystem. This will support different filesystems including the FAT32, EXFAT, NTFS etc. You can perform an internal walkthrough for both the physical disk as well as the software image file. As the tool name suggests, you can edit different file system fields.  https://www.disk-editor.org/index.html

  • Frhed:                                                                                                                                                 This is a light weight binary editor for windows. You can edit different kinds of files including the pcap file, image file etc. This also allows you to even truncate the file as well.http://frhed.sourceforge.net/en/
  • Win 32 Disk Imager:                                                                                                                          I think lot of people are familiar with this tool. Win 32 Disk Imager is used for writing, reading and verifying the image to and from the SD cards.  https://sourceforge.net/projects/win32diskimager/
  • Whack Whack Terminal:                                                                                                                  Another visual studio plugin, this will allow you to open different terminals including bash, windows in the visual studio project window. The main advantage of this tool is you can execute CLI commands without switching the Visual Studio Application. https://marketplace.visualstudio.com/items?itemName=dos-cafe.WhackWhackTerminal

Saturday, 10 October 2020

Useful tools for Software Developers - Part 1

I would like to introduce some useful open source tools which I used for my previous projects.   
  • Dibbler Dhcpv6 Server
A light weight command line Dhcpv6 server. This software will actually include both dhcpv6 client and server. Useful for testing both client and server code.http://klub.com.pl/dhcpv6/
  • Technitium DNS Server
Good looking DNS Server with online dashboard available for configuration. This will support both IPV4 and IPV6, so it can be used with either DHCP or DHCPV6 server for testing.https://technitium.com/dns/
  • DHCP Server for Windows
Small DHCP server with decent UI and easily configurable.https://www.dhcpserver.de/cms/download/
  • TCP REPLAY:
Command line tool used for sending pre captured packets to a particular interface. This will be very handy when you want to verify the behavior of client or server with erroneous packets. Installation is bit tricky in windows, you require libpcap and cygwin.                                         https://tcpreplay.appneta.com/#:~:text=Tcpreplay%20is%20a%20suite%20of,to%20replay%20to%20web%20servers.
  • PCATTCP or TTCP:
Command line tool used for testing the performance of TCP and UDP. If you want to verify your TCP or UDP code,  then this will a good tool for this. Both windows and linux compatible. Simple Usage: Open 2 command lines one as a reciever and other as a transmitter. Official page is not working but you can download from this website.
  • UNCRUSTIFY:
An open source code beautifier for C, C++, JAVA etc.                                          https://github.com/uncrustify/uncrustify