Skip to content

Technical Knowledge

Comparing FTP and SFTP Protocols (Port 21 vs 22) for Environmental Telemetry

Comprehensive technical comparison between FTP (Port 21) and SFTP (Port 22) protocols for transmitting environmental monitoring data to DONRE.

R&D & Turnkey OEM Manufacturing →
Comparing FTP and SFTP Protocols (Port 21 vs 22) for Environmental Telemetry

Selecting the proper data transmission protocol—FTP (File Transfer Protocol - Port 21) or SFTP (SSH File Transfer Protocol - Port 22)—is a vital technical decision when commissioning automated environmental monitoring stations transmitting data to provincial Departments of Natural Resources and Environment (DONRE) under Circular 10/2021/TT-BTNMT and Circular 17/2021/TT-BTNMT. While legacy FTP has been the historical default across Vietnam, environmental authorities in progressive industrial provinces (such as Binh Duong, Dong Nai, Ba Ria - Vung Tau, and Hanoi) are aggressively transitioning to encrypted SFTP to eliminate cyber vulnerabilities and prevent man-in-the-middle data tampering.

This technical guide is part of DeviceLab's comprehensive engineering handbook on environmental monitoring datalogger compliant with Circular 10.

For instrumentation technicians in the field, network connection failures remain the single most frustrating bottleneck. Many engineers encounter the classic, baffling anomaly: the datalogger authenticates and logs in successfully, but uploads 0-byte empty files, or hangs endlessly during data transfer. This technical guide explains the architectural divergence between FTP and SFTP, resolves cellular 4G NAT firewall traps (Active vs. Passive Mode), and details the dual-protocol engine built into the DeviceLab DL-ENV10 Datalogger.

Key Differences at a Glance (FTP vs. SFTP):

  • FTP (File Transfer Protocol - Port 21): Cleartext unencrypted transmission with split dual channels (Control Channel on Port 21, Data Channel on random high ports). Highly vulnerable to cellular 4G CGNAT blocks unless Passive Mode (PASV) is explicitly enforced.
  • SFTP (SSH File Transfer Protocol - Port 22): Entirely unrelated to FTP. Runs on the secure SSH-2 protocol, bundling control commands and file data inside a single, encrypted bidirectional stream on Port 22 protected by AES-256 and RSA public keys.
  • Regulatory Direction: Circular 10 permits both protocols, but provincial DONRE centers increasingly mandate SFTP to comply with national governmental cybersecurity directives.
  • Datalogger Telemetry Unit: DeviceLab DL-ENV10 supporting native dual-stack FTP and SFTP clients with automated connection fallbacks.
Comparing FTP and SFTP Protocols for Environmental Telemetry Data Transmission
Figure 16: Terminal diagnostic session illustrating encrypted SSH key exchange and SFTP transfer over Port 22 to provincial DONRE server.

The Structural Shift from FTP to SFTP Across Provincial DONRE Centers

For over a decade, cleartext FTP served as the foundational transmission mechanism for environmental monitoring in Vietnam. However, FTP transmits usernames, passwords, and measurement records in unencrypted plain text over public cellular networks. Anyone equipped with basic network packet sniffers (such as Wireshark) can intercept credentials or execute man-in-the-middle packet spoofing.

To comply with national critical infrastructure cybersecurity laws, provincial DONRE IT departments are systematically replacing cleartext FTP servers with hardened SFTP (SSH-2) servers. SFTP enforces end-to-end symmetric encryption (AES-128 / AES-256), cryptographic packet integrity hashing (HMAC-SHA-256), and optional RSA/ECDSA public-key authentication, guaranteeing that data received by the environmental center originated authentically from the licensed datalogger.

Troubleshooting the Classic Error: "Login Successful but Creates 0-Byte File"

The most pervasive troubleshooting ticket submitted by field engineers is: "The datalogger logs into DONRE FTP successfully, sends the command, creates a text file on the remote server, but the file size remains exactly 0 bytes and the session hangs."

2.1. Root Cause: Active Mode (PORT) Blocked by Cellular 4G NAT Firewalls

Legacy FTP operates in two modes: Active (PORT) and Passive (PASV):

  • In Active Mode, the datalogger connects out to the DONRE server on Port 21 (Control Channel). But when file data is sent, the server initiates an inbound connection back to the datalogger on a dynamic TCP port.
  • Because industrial dataloggers utilize cellular 4G SIM cards, mobile network operators place them behind strict Carrier-Grade NAT (CGNAT) and internal firewalls. The server's inbound connection attempt is immediately dropped by the cellular carrier. The control session stays open, creating a 0-byte file header, but the actual payload never transfers!

2.2. Definitive Fix: Enabling Passive Mode (PASV) or Migrating to SFTP

To fix this error, engineers must force the datalogger to use Passive Mode (PASV), where both the control channel and data channel originate as outbound connections from the datalogger. Even better: migrate to SFTP, which eliminates secondary data channels altogether, routing all commands and file streams through a single outbound connection on Port 22 that breezes through 4G carrier firewalls.

Comprehensive Technical Comparison: FTP vs. FTPS vs. SFTP

Technical Criteria FTP (File Transfer Protocol) FTPS (FTP over SSL/TLS) SFTP (SSH File Transfer Protocol)
Standard Server Port Port 21 Port 990 / 21 Port 22
Data & Credential Encryption None (Plaintext cleartext) TLS/SSL Encryption Full SSH-2 Encryption (AES-256)
Network Channel Architecture Dual channel (Control + Data) Dual channel (Control + Data) Single multiplexed connection
Cellular 4G Firewall Traversal Poor (Requires explicit PASV mode) Poor (Complex dynamic ports) Exceptional (Single outbound port)
DONRE Modern Acceptance Legacy standard (Phasing out) Rarely deployed in Vietnam Top recommendation & future standard

Frequently Asked Questions (FAQ)

About the author

Written by

✓ E-E-A-T Verified Engineer

Thao Dinh – Lead Embedded Systems Engineer

Lead Embedded Systems & Hardware R&D, DeviceLab

🎓 Kỹ sư Điện tử - Viễn thông (ĐHBK Hà Nội) · 12+ năm R&D Phần cứng Nhúng & IoT

Technical Review

DeviceLab Engineering Team

Peer-reviewed for circuit schematic topology, bus signal integrity, and compliance standards (QCVN / TT10 BTNMT).

Last updated: 17/10/2026

Specialization: Hardware · PCB · Embedded · Prototype

View DeviceLab engineered projects & case studies →

Related Technical Articles & Engineering Guides

Deepen your engineering knowledge with practical guides from DeviceLab engineers:

Recommended Industrial IoT Hardware & OEM Solutions

Standardized industrial-grade devices engineered and mass-produced by DeviceLab Vietnam:

ĐIỀU 39 TT10 · FTPS 5 PHÚT DL-ENV10: datalogger quan trắc môi trường thông tư 10 Đạt chuẩn quy chuẩn datalogger điều 39 thông tư 10, lưu đệm Flash > 180 ngày, pin UPS 6–8h. CÁCH LY 3.0kV · DIN-RAIL DL-RS485: RS485 sang Ethernet Chuyển đổi Modbus RTU sang Modbus TCP, chống nhiễu biến tần 24/7. MQTT · CLOUD API · 4G DL-GW200: Industrial IoT Gateway Thu thập Modbus RS485 đẩy MQTT/API, bộ nhớ đệm Flash 100k bản ghi. 4 CỔNG RS485 · THÔNG TƯ 10 DL-GW400: Edge Gateway & Datalogger Bộ tập trung 4 cổng RS485 độc lập cho quan trắc môi trường và năng lượng.
Explore Solutions: Custom PCB & Circuit Design • PCBA & SMT Assembly • Embedded Firmware Engineering • Turnkey IoT Device R&D • Circular 10 Environmental Datalogger • Machinery IoT Modules • OEM Gateways for SIs • Factory Energy Telemetry • White-Label IoT Platform • Batch Manufacturing & QC • Hardware R&D Partner • Why DeviceLab

Need custom hardware design or embedded device engineering?

You do not need a complete schematic. Describe your functional specifications, target application, and power/size/connectivity constraints.

Submit Project Requirements

DeviceLab helps define engineering scope from architecture to functional prototype.