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.