[Amazon FSx for NetApp ONTAP] SMBのWrite LengthとRead Lengthをパケットキャプチャして確認してみた

[Amazon FSx for NetApp ONTAP] SMBのWrite LengthとRead Lengthをパケットキャプチャして確認してみた

ファイルサイズとアプリケーションによってWrite LengthとRead Lengthは大きく変わる
Clock Icon2025.02.12

SMBでファイルの読み書きをする際のデフォルトのサイズが気になる

SMBでファイルの読み書きをする際のデフォルトのサイズが気になったことはありますか?

以下記事で、fioでブロックサイズを変更しながらSMB暗号化有効化時のパフォーマンスの影響を確認しました。

https://dev.classmethod.jp/articles/amazon-fsx-for-netapp-ontap-smb-encryption-performance-comparison/

もし、ブロックサイズを指定しない場合はどのようなサイズになるのでしょうか。

例えば、エクスプローラーでファイルをコピーする際に発生するSMBの裏側の読み書きのサイズを指定することはほとんどないと思います。

気になってみたので、実際に確認してみます。

いきなりまとめ

  • Amazon FSx for NetApp ONTAPのMax Read Sizeおよび、Max Write Sizeのどちらも1048576 = 1MiB固定

    • スループットキャパシティを変更しても値は変動しない
  • アプリケーションとファイルサイズごとのRead Length / Write Lengthは以下のとおり

    アプリケーション ファイルサイズ Write Length Read Length
    エクスプローラー 256KiB 128KiB -
    エクスプローラー 4MiB 512KiB 512KiB
    エクスプローラー 64MiB 1MiB -
    PowerShell 4MiB 512KiB -
    fio 64KiB 4KiB (ブロック指定) -
    メモ帳 256KiB - 32KiB
    メモ帳 4MiB - 32KiB→4KiB→1MiB
    メモ帳 64MiB - 32KiB→4KiB→1MiB
    LibreOffice Impress 13MiB - 4KiB〜252KiB
  • エクスプローラーやPowerShellなどファイル全体の読み書きはファイルサイズが大きくなるにつれて、Read Length / Write Lengthが大きくなる傾向がある

  • ファイルオープン時はアプリケーションによってRead Lengthが大きく異なる

    • メモ帳は先頭は32KiB固定で、読み込みに時間がかかる場合は読み込みサイズが大きくなる
    • LibreOffice Impressは4KiB〜252KiB程度のサイズで読み込みが発生する (最頻値は4KiB)

検証環境

検証環境は以下のとおりです。

[Amazon FSx for NetApp ONTAP] SMBのWrite LengthとRead Lengthをパケットキャプチャして確認してみた検証環境構成図.png

SMBクライアントのEC2インスタンスからSMBでファイルの読み書きをして、その時発生するSMBの読み書きのサイズを確認します。

EC2インスタンスはWindows_Server-2022-English-Full-Base-2024.07.10から作成しました。また、インスタンスタイプはt3.largeです。

Amazon FSx for NetApp ONTAP(以降FSxN)ファイルシステムのスループットキャパシティは128MBpです。

使用するSMBファイル共有は以下記事で作成したprevious-version-test-shareです。

https://dev.classmethod.jp/articles/amazon-fsx-for-netapp-ontap-explorer-previous-version-restore-snapshot-diff/

FSxNのSMBサーバーの各種設定は以下のとおりです。

::*> cifs options show -instance -vserver svm

Vserver: svm

                            Client Session Timeout: 900
                              Copy Offload Enabled: false
                                Default Unix Group: -
                                 Default Unix User: pcuser
                                   Guest Unix User: -
               Are Administrators mapped to 'root': true
           Is Advanced Sparse File Support Enabled: true
                  Is Fsctl File Level Trim Enabled: true
                  Direct-Copy Copy Offload Enabled: false
                           Export Policies Enabled: false
            Grant Unix Group Permissions to Others: false
                          Is Advertise DFS Enabled: false
     Is Client Duplicate Session Detection Enabled: true
               Is Client Version Reporting Enabled: true
                                    Is DAC Enabled: false
                      Is Fake Open Support Enabled: true
                         Is Hide Dot Files Enabled: false
                              Is Large MTU Enabled: true
                             Is Local Auth Enabled: true
                 Is Local Users and Groups Enabled: true
                           Is Multichannel Enabled: true
            Is NetBIOS over TCP (port 139) Enabled: true
               Is NBNS over UDP (port 137) Enabled: false
                               Is Referral Enabled: false
             Is Search Short Names Support Enabled: false
  Socket Option KEEPIDLE of Connections in Seconds: 0
  Is Trusted Domain Enumeration And Search Enabled: true
                        Is UNIX Extensions Enabled: false
          Is Use Junction as Reparse Point Enabled: true
    Maximum Length of Data Zeroed by One Operation: 32MB
                               Max Multiplex Count: 255
          Max Connections per Multichannel Session: 32
                 Max LIFs per Multichannel Session: 256
              Max Same User Session Per Connection: 2500
                 Max Same Tree Connect Per Session: 5000
                      Max Opens Same File Per Tree: 1000
                          Max Watches Set Per Tree: 500
                   Is Path Component Cache Enabled: true
Is Path Component Cache Symlink Resolution Enabled: true
              Path Component Cache Maximum Entries: 100000
        Path Component Cache Entry Expiration Time: 300000
      Path Component Cache Symlink Expiration Time: 300000
   Path Component Cache Maximum Session Token Size: 1000
    NT ACLs on UNIX Security Style Volumes Enabled: true
                                  Read Grants Exec: disabled
                                  Read Only Delete: disabled
                  Reported File System Sector Size: 4096
                                Restrict Anonymous: no-enumeration
                              Shadowcopy Dir Depth: 5
                                Shadowcopy Enabled: true
                                      SMB1 Enabled: false
                  Max Buffer Size for SMB1 Message: 65535
                                      SMB2 Enabled: true
                                      SMB3 Enabled: true
                                    SMB3.1 Enabled: true
            Map Null User to Windows User or Group: -
                                      WINS Servers: -
         Report Widelink as Reparse Point Versions: SMB1
                              Max Credits to Grant: 512
         Set Modebits when NFSv4_acl are Inherited: false
                       Map SID to UID on Set Owner: true
Check Share Permission for NetShareEnumAll Request: false
   Preserve UNIX Symlink During Backup through SMB: false


::*> cifs security show -instance -vserver svm

Vserver: svm

                            Kerberos Clock Skew:                   5 minutes
                            Kerberos Ticket Age:                  10 hours
                           Kerberos Renewal Age:                   7 days
                           Kerberos KDC Timeout:                   3 seconds
                            Is Signing Required:               false
                Is Password Complexity Required:                true
           Use start_tls for AD LDAP connection:               false
         (DEPRECATED)-Is AES Encryption Enabled:                true
                         LM Compatibility Level:  lm-ntlm-ntlmv2-krb
                     Is SMB Encryption Required:               false
                        Client Session Security:                none
   (DEPRECATED)-SMB1 Enabled for DC Connections:               false
                SMB2 Enabled for DC Connections:      system-default
  LDAP Referral Enabled For AD LDAP connections:               false
               Use LDAPS for AD LDAP connection:               false
      Encryption is required for DC Connections:               false
   AES session key enabled for NetLogon channel:                true
    Try Channel Binding For AD LDAP Connections:                true
        Encryption Types Advertised to Kerberos:
                                          aes-256, aes-128, rc4, des

MTUの確認

まず、MTUを確認します。

SMBセッションが存在しない状態で、エクスプローラーからSMBファイル共有にアクセスします。

すると、TCP Option内にMSS Value8961という値を確認できます。

1.MSSの確認.png

10.0.8.246はSMBサーバーのIPアドレスで、10.0.0.34はEC2インスタンスのIPアドレスです。

そのため、送信元がSMBサーバーで送信先がEC2インスタンスであるため、8961はSMBサーバー側のMSSであることが分かります。

MTUはMSSからTCPヘッダ(20Byte)とIPヘッダ(20Byte)を除いたサイズなので、9001であることが分かります。

また、InfoからEC2インスタンスのMTUは1460+20=1500であることも確認できます。

これはWindowsのEC2インスタンスはデフォルトでジャンボフレームが無効化されているためです。

> Get-NetAdapterAdvancedProperty -Name "Ethernet*"

Name                      DisplayName                    DisplayValue                   RegistryKeyword RegistryValue
----                      -----------                    ------------                   --------------- -------------
Ethernet 3                IPv4 Checksum offload          Rx & Tx Enabled                *IPChecksumO... {3}
Ethernet 3                Jumbo Packet                   Disabled                       *JumboPacket    {1514}
Ethernet 3                Large Send Offload V1 (IPv4)   Enabled                        *LsoV1IPv4      {1}
Ethernet 3                Large Send Offload V2 (IPv4)   Enabled                        *LsoV2IPv4      {1}
Ethernet 3                Large Send Offload V2 (IPv6)   Enabled                        *LsoV2IPv6      {1}
Ethernet 3                Maximum Number of RSS Queues   32                             *NumRssQueues   {32}
Ethernet 3                Priority and Vlan Support      Both                           *PriorityVLA... {3}
Ethernet 3                Receive Buffers                1024                           *ReceiveBuffers {1024}
Ethernet 3                Receive Side Scaling           Enabled                        *RSS            {1}
Ethernet 3                TCP Checksum Offload (IPv4)    Rx & Tx Enabled                *TCPChecksum... {3}
Ethernet 3                TCP Checksum Offload (IPv6)    Rx & Tx Enabled                *TCPChecksum... {3}
Ethernet 3                Transmit Buffers               1024                           *TransmitBuf... {1024}
Ethernet 3                UDP Checksum Offload (IPv4)    Rx & Tx Enabled                *UDPChecksum... {3}
Ethernet 3                UDP Checksum Offload (IPv6)    Rx & Tx Enabled                *UDPChecksum... {3}
Ethernet 3                LLQ Header Size Policy         Recommended                    LlqPolicy       {0}
Ethernet 3                Metrics Refresh Interval       1                              MetricsRefre... {1}
Ethernet 3                MAC Address                    --                             NetworkAddress  {--}
Ethernet 3                VLAN ID                        0                              VlanId          {0}

ENAドライバーのWindowsインスタンスでジャンボフレームを有効化する場合はSet-NetAdapterAdvancedProperty -Name "Ethernet" -RegistryKeyword "*JumboPacket" -RegistryValue 9015を実行します。

https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-instance-mtu.html

SMB2 negotiateの確認

SMBのセッションを張る際には、SMB2 negotiateが行われます。

具体的にはSMBサーバーとクライアント間で以下のようなやりとりが発生します。

  1. SMB2 NEGOTIATE Request
  2. SMB2 NEGOTIATE Response
  3. SMB2 SESSION_SETUP Request 1
  4. SMB2 SESSION_SETUP Response 1
  5. SMB2 SESSION_SETUP Request 2
  6. SMB2 SESSION_SETUP Response 2
  7. SMB2 TREE_CONNECT Request
  8. SMB2 TREE_CONNECT Response

image009.png

抜粋 : [MS-SMB2]: Connecting to a Share by Using an SMB2 Negotiate | Microsoft Learn

SMB2 NEGOTIATE Responseのドキュメントを見ると、以下のような記載がありました。

MaxTransactSize (4 bytes): The maximum size, in bytes, of the buffer that can be used for QUERY_INFO, QUERY_DIRECTORY, SET_INFO and CHANGE_NOTIFY operations. This field is applicable only for buffers sent by the client in SET_INFO requests, or returned from the server in QUERY_INFO, QUERY_DIRECTORY, and CHANGE_NOTIFY responses.<27>

MaxReadSize (4 bytes): The maximum size, in bytes, of the Length in an SMB2 READ Request (section 2.2.19) that the server will accept.

MaxWriteSize (4 bytes): The maximum size, in bytes, of the Length in an SMB2 WRITE Request (section 2.2.21) that the server will accept.

[MS-SMB2]: SMB2 NEGOTIATE Response | Microsoft Learn

要するに、ここでSMBサーバーが受け入れられる書き込み読み込みのサイズが指定されていることが分かります。

実際に確認してみると、Max Read Sizeおよび、Max Write Sizeのどちらも1048576 = 1MiBでした。

2.SMB2 NEGOTIATE Response.png

SMBの書き込み

エクスプローラーにファイルをコピーアンドペースト (4MiB)

実際にどのようなサイズで書き込まれるのか確認しましょう。

SMBを介してファイルを書き込む際には以下のようなやりとりが発生します。

image012.png

抜粋 : [MS-SMB2]: Writing to a Remote File | Microsoft Learn

実際にファイルを書き込むのはSMB2 WRITE Requestです。

SMB2 WRITE RequestSMB2 WRITE Responseのドキュメントを確認します。

SMB2 WRITE Request内のDataOffsetLengthを見れば良さそうです。

DataOffset (2 bytes): The offset, in bytes, from the beginning of the SMB2 header to the data being written.

Length (4 bytes): The length of the data being written, in bytes. The length of the data being written can be zero bytes.

[MS-SMB2]: SMB2 WRITE Request | Microsoft Learn

まずは、エクスプローラーにファイルをコピーアンドペーストする場合です。

以下コマンドで生成したファイルを書き込みます。

$ yes \
  `printf %b $(printf '\\%03o' {32..126})` | \
  tr -d ' ' | \
  dd \
    bs=16K \
    count=256 \
    of=ASCII_4MiB.txt
256+0 records in
256+0 records out
4194304 bytes transferred in 0.188794 secs (22216299 bytes/sec)

$ head -c 3 ./ASCII_4MiB.txt
!"#bash-5.2$
bash-5.2$ head -n 3 ./ASCII_4MiB.txt
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

パケットキャプチャの結果は以下のとおりです。

3.エクスプローラーから4MiBのファイルの書き込み時_Write Length.png

一度のWrite Requestで524,288 Byte = 512KiB書き込んでいることが分かります。

次のWrite RequestのOff(File Offset)に注目すると、5242881048576と524,288 Byteづつ増えていることも分かります。

最後のWrite RequestのFile Offset3670016にWrite Lengthである524288を足すと、4,194,304となります。これはコピー対象のファイルのサイズと完全に一致しています。

また、Write Requestは512KiBですが、実際はTCPパケットのサイズにフラグメンテーションされて送信されています。

確認すると、21,900 Byteや11,680 Byteなどのサイズで21個ほどのセグメントにフラグメンテーションされていました。

4.エクスプローラーから4MiBのファイルの書き込み時_Segment.png

検証で使用したEC2インスタンスはTCP Segmentation Offload(TSO)が有効であるため、パケットキャプチャ上ではMTUのサイズには分割されていないように見えます。

複数回このファイルを書き込んでみましたが、いずれもWrite Lengthは512KiBでした。

なお、この時はSMB3.1で接続しています。

::*> cifs session show -instance

Vserver: svm

                            Node: FsxId0e64a4f5386f74c87-01
                      Session ID: 16182559361049034765
                   Connection ID: 671331449
    Incoming Data LIF IP Address: 10.0.8.246
          Workstation IP Address: 10.0.0.34
        Authentication Mechanism: Kerberos
           User Authenticated as: domain-user
                    Windows User: CORP\Administrator
                       UNIX User: root
                     Open Shares: 1
                      Open Files: 3
                      Open Other: 0
                  Connected Time: 19m 53s
                       Idle Time: 9m 6s
                Protocol Version: SMB3_1
          Continuously Available: No
               Is Session Signed: false
                    NetBIOS Name: -
           SMB Encryption Status: unencrypted
               Large MTU Enabled: true
                Connection Count: 1
                   Active Shares: previous-version-test-share

エクスプローラーにファイルをコピーアンドペースト (64MiB)

ファイルサイズが影響あるのでしょうか。

64MiBのファイルを転送してみます。

ファイルを作成します。

$ yes \
  `printf %b $(printf '\\%03o' {32..126})` | \
  tr -d ' ' | \
  dd \
    bs=16K \
    count=4K \
    of=ASCII_64MiB.txt
4096+0 records in
4096+0 records out
67108864 bytes transferred in 3.391273 secs (19788694 bytes/sec)

作成したファイルをエクスプローラーにファイルをコピーアンドペーストします。

この時のパケットキャプチャの結果は以下のとおりです。

5.エクスプローラーから64MiBのファイルの書き込み時_Segment.png

Write Lengthは1048576 = 1MiBとMax Write Lengthと一致するほどまで大きくなっていました。

また、何回同じファイルを書き込んでも1MiBでした。

エクスプローラーにファイルをコピーアンドペースト (256KiB)

小さいファイルサイズの場合も確認します。

256KiBのファイルを転送してみます。

ファイルを作成します。

$ yes \
  `printf %b $(printf '\\%03o' {32..126})` | \
  tr -d ' ' | \
  dd \
    bs=16K \
    count=16 \
    of=ASCII_256KiB.txt
16+0 records in
16+0 records out
262144 bytes transferred in 0.010351 secs (25325476 bytes/sec)

作成したファイルをエクスプローラーにファイルをコピーアンドペーストします。

この時のパケットキャプチャの結果は以下のとおりです。

6.エクスプローラーから256KiBのファイルの書き込み時_Segment.png

Write Lengthは131072 = 128KiBと小さくなっていました。

以上の検証から、少なくともSMB 3.1の場合、ファイルサイズよってWrite Requestのサイズが変動することが分かります。

PowerShellでファイルをコピー (書き込み)

PowerShellからの操作でWrite Lengthが変わるのかも確認します。

> cp .\ASCI_4MiB.txt \\SMB-SERVER.corp.non-97.net\previous-version-test-share\

この時のパケットキャプチャの結果は以下のとおりです。

7.PowerShellから64MiBのファイルの書き込み時_Segment.png

Write Lengthは524288 = 512KiBとエクスプローラーでコピーした場合と同じですね。

fioで書き込み (ブロックサイズ4KiB)

せっかくなので、fioで書き込んだ場合のWrite Lengthも確認します。

ブロックサイズは4KiBを指定します。

> fio `
  --directory=\\SMB-SERVER.corp.non-97.net\previous-version-test-share\ `
  --name fio_randwrite_4KiB_block_64KiB_4jobs `
  --ioengine=windowsaio `
  --direct=1 `
  --iodepth=1 `
  --rw=randwrite `
  --bs=4K `
  --size=64K `
  --numjobs=4 `
  --eta-newline=10 `
  --group_reporting `
  --norandommap
fio: this platform does not support process shared mutexes, forcing use of threads. Use the 'thread' option to get rid of this warning.
fio_randwrite_4KiB_block_64KiB_4jobs: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=windowsaio, iodepth=1
...
fio-3.38
Starting 4 threads
fio_randwrite_4KiB_block_64KiB_4jobs: Laying out IO file (1 file / 0MiB)
fio_randwrite_4KiB_block_64KiB_4jobs: Laying out IO file (1 file / 0MiB)

fio_randwrite_4KiB_block_64KiB_4jobs: (groupid=0, jobs=4): err= 0: pid=2472: Tue Feb 11 13:07:46 2025
  write: IOPS=1641, BW=6564KiB/s (6722kB/s)(256KiB/39msec); 0 zone resets
    slat (usec): min=16, max=3652, avg=170.59, stdev=500.87
    clat (usec): min=24, max=9677, avg=1005.81, stdev=1839.81
     lat (usec): min=428, max=9712, avg=1176.40, stdev=1859.90
    clat percentiles (usec):
     |  1.00th=[   25],  5.00th=[   67], 10.00th=[  383], 20.00th=[  416],
     | 30.00th=[  453], 40.00th=[  482], 50.00th=[  494], 60.00th=[  529],
     | 70.00th=[  562], 80.00th=[  660], 90.00th=[ 1303], 95.00th=[ 4228],
     | 99.00th=[ 9634], 99.50th=[ 9634], 99.90th=[ 9634], 99.95th=[ 9634],
     | 99.99th=[ 9634]
  lat (usec)   : 50=3.12%, 100=3.12%, 250=1.56%, 500=43.75%, 750=32.81%
  lat (usec)   : 1000=3.12%
  lat (msec)   : 2=4.69%, 10=7.81%
  cpu          : usr=0.00%, sys=0.00%, ctx=0, majf=0, minf=0
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,64,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
  WRITE: bw=6564KiB/s (6722kB/s), 6564KiB/s-6564KiB/s (6722kB/s-6722kB/s), io=256KiB (262kB), run=39-39msec

この時のパケットキャプチャの結果は以下のとおりです。

8.fioで4KiBブロックで書き込み時.png

Write Lengthは4096 = 4KiBとブロックサイズで指定したとおりですね。

SMBの読み込み

エクスプローラーからファイルをコピーアンドペースト (4MiB)

SMBの読み込みも確認します。

SMBを介してファイルを読み込む際には以下のようなやりとりが発生します。

image011.png

抜粋 : [MS-SMB2]: Reading from a Remote File | Microsoft Learn

実際にファイルを読み込むのはSMB2 READ Responseです。

SMB2 READ RequestSMB2 READ Responseのドキュメントを確認します。

SMB2 READ Response内のDataOffsetLengthを見れば良さそうです。

DataOffset (2 bytes): The offset, in bytes, from the beginning of the SMB2 header to the data being written.

Length (4 bytes): The length of the data being written, in bytes. The length of the data being written can be zero bytes.

[MS-SMB2]: SMB2 WRITE Request | Microsoft Learn

まず、エクスプローラーからファイルをコピーアンドペーストして、手元にコピーする場合です。

4MiBのファイルをコピーした場合のパケットキャプチャの結果は以下のとおりです。

9.エクスプローラーから4MiBのファイルの読み込み時_Read Length.png

Read Lengthは524288 = 512KiBと書き込みした際と同じです。

このことから読み込みと書き込みのサイズは基本的にファイルサイズで決定されそうです。

なお、Read Responseを確認すると、512KiBをMSSである1,460Byte単位でセグメンテーションされたことを確認できます。

10.エクスプローラーから4MiBのファイルの読み込み時_Segment.png

メモ帳でファイルをオープン (64MiB)

64MiBのファイルをメモ帳でオープンします。この時のパケットキャプチャの結果は以下のとおりです。

11.メモ帳で64MiBのファイルの読み込み時_Read Length1.png

Read Lengthは途中までは32768 = 32KiBでしたが、32KiB→4KiB→1MiBと途中で変わりました。以降は1MiBのままです。

最初は先頭部分を素早く表示するために小さいサイズで読み込んで、後から大きなサイズに変わったのかもしれません。

要するにアプリケーションによって読み書きのサイズは変動しそうであることが分かりました。

メモ帳でファイルをオープン (256KiB)

試しに256KiBのファイルもメモ帳でオープンしてみます。

この時のパケットキャプチャの結果は以下のとおりです。

12.メモ帳で256KiBのファイルの読み込み時_Read Length1.png

Read Lengthは最初から32KiBです。256KiBのファイルを書き込む際は128KiBでした。メモ帳はファイルをオープンして先頭部分を読み込む際には32KiB固定で読み込むのかもしれません。

メモ帳でファイルをオープン (4MiB)

4MiBのファイルもメモ帳でオープンしてみます。

この時のパケットキャプチャの結果は以下のとおりです。

13.メモ帳で4MiBのファイルの読み込み時_Read Length1.png

Read Lengthは最初は32KiBで、途中から32KiB→4KiB→1MiBに変化しました。やはり、メモ帳については先頭読み込みサイズは32KiB固定で、読み込みに時間がかかる場合は読み込みサイズが大きくなるようです。

プレゼンテーションファイルの読み込み

メモ帳以外にも試してみます

LibreOffice Impressでプレゼンテーションファイルを開きます。

対象のファイルはAWS アーキテクチャアイコンAWS-Architecture-Icons-Deck_For-Light-BG_06072024.pptxです。

SMBファイル共有に接続しているエクスプローラーにコピーアンドペーストして、SMBファイル共有内に書き込まれた時のパケットキャプチャも確認します。

17.LibreOffice Impressで13MiBのファイルの読み込み時_Write Length.png

Write Lengthは232KiBから1MiBと幅があります。

Write Lengthごとの出現回数は以下のとおりです。

$ tshark \
  -r 13MiB_file_write_explorer.pcapng \
  -Y "smb2.cmd == 9 &&  smb2.flags.response == 0" \
  -T fields -e smb2.write_length \
  | sort -n \
  | uniq -c \
  | sort -nr
   7 1048576
   2 811008
   2 237568
   1 551920

ファイルサイズが大きいだけあって、1MiBが一番多いですね。

それではLibreOffice Impressでファイルを開きます。

14.LibreOffice Impressで13MiBのファイルの読み込み時_Read Length1.png

はい、Read Lengthはかなりまちまちです。

読み込み終盤のRead Requestも確認しましたが、Read Lengthは一定ではありませんでした。

15.LibreOffice Impressで13MiBのファイルの読み込み時_Read Length2.png

ぱっと見では4KiBが多そうですね。

Read Lengthごとの出現回数は以下のとおりです。

$ tshark \
  -r 13MiB_file_read_Impress.pcapng \
  -Y "smb2.cmd == 8 &&  smb2.flags.response == 0" \
  -T fields -e smb2.read_length \
  | sort -n \
  | uniq -c \
  | sort -nr
 193 4096
  10 262144
   8 8192
   5 253952
   4 73728
   4 32768
   4 28672
   4 221184
   3 40960
   3 258048
   3 188416
   3 151552
   2 98304
   2 86016
   2 77824
   2 57344
   2 49152
   2 249856
   2 241664
   2 225280
   2 212992
   2 163840
   2 12288
   2 1024
   1 69632
   1 65536
   1 61440
   1 31728
   1 245760
   1 24576
   1 237568
   1 233472
   1 200704
   1 196608
   1 184320
   1 176128
   1 155648
   1 147456
   1 131072
   1 114688
   1 110592
   1 106496
   1 102400

確かに4KiBが最頻出のようです。

100KiB単位での出現回数も確認してみます。

$ tshark \
  -r 13MiB_file_read_Impress.pcapng \
  -Y "smb2.cmd == 8 && smb2.flags.response == 0" \
  -T fields -e smb2.read_length \
  | awk '
    {
      count[int($1/102400)]++
    }
    END {
      for (i in count)
        printf("%d-%d KiB: %d\n", i*100, (i+1)*100-1, count[i])
    }' \
  | sort -n
0-99 KiB: 235
100-199 KiB: 19
200-299 KiB: 33

300KiB以上のRead LengthのRead Requestは発生していないことが分かります。

エクスプローラーやPowerShellなどファイル全体の読み書きはファイルサイズが大きくなるにつれて、Read Length / Write Lengthが大きくなる傾向はありますが、ファイルをオープンするの際のRead Length / Write Lengthはアプリケーション次第に大きく異なりそうです。

スループットキャパシティを変更してMax Write SizeやMax Read Sizeが変動するか

最後に、スループットキャパシティを変更してMax Write SizeやMax Read Sizeが変動するか確認します。

スループットキャパシティを128MBpsから512MBpsに変更します。

16.スループットキャパシティを512MBpsに変更.png

変更されたことを確認します。

18.スループットキャパシティを512MBpsに変更2.png

この状態でSMBファイル共有にアクセスして、SMB2 negotiateを確認します。

19.スループットキャパシティを512MBpsに変更した後のMax.png

Max Read Sizeおよび、Max Write Sizeのどちらも変わらず1048576 = 1MiBでした。

fioddなどでブロックサイズをしている際は1MiB以上を指定しても、意味はなさそうですね。

ファイルサイズとアプリケーションによってWrite LengthとRead Lengthは大きく変わる

Amazon FSx for NetApp ONTAPを使って、SMBのWrite LengthとRead Lengthをパケットキャプチャして確認してみました。

結論、ファイルサイズとアプリケーションによってWrite LengthとRead Lengthは大きく変わります。

FSxN上でベンチマークを実行する際は、保存するファイルのファイルサイズの割合、使用するアプリケーションを事前に確認しておくと、有意義なベンチマークが取れるでしょう。

この記事が誰かの助けになれば幸いです。

以上、クラウド事業本部 コンサルティング部の のんピ(@non____97)でした!

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.