STM32 Experiment & Note —— (033) MTU TCP SOCKET (Not translated)
»
(001) HAL Library LED Lighting
(002) HAL Library LCD Frame Animation
(003) HAL Library FFT Dynamic Spectrum
(004) HAL Library FFT Speed Up
(005) HAL Library Understanding DMA
(006) Watchdog Summary
(007) GPIO Usage Steps
(008) CubeIDE Implementation of USB Peripherals*
(009) Why C99
(010) Linux UDP
(011) Linux TCP
(012) Temperature Control of Arm
(013) OpenWrt cross-compilation
(014) Basic data type in C99
(015) C99 struct
(016) C99 enum
(017) C99 funciont and L-Value, R-Value
(018) C99 pointer*
(019) C99 With only value assignment*
(020) C99 array with space, pointer with no space
(021) C99 No template function
(022) POSIX pthread multi-threads mutex*
(023) POSIX pthread multi-threads programming*
(024) C99 if
(025) C99 switch
(026) C99 loop
(027) C99 time and wait*
(028) High-precision calculation with GMP*
(029) Web Service Lib*
(030) International Components for Unicode (ICU)*
(031) Performance of C is higher than C++, because...*
(032) C99 weak function
(033) MTU TCP SOCKET
(034) STM32 UART Continually Sending Data
(035) STM32 UART Continually Receiving Data
(037) STM32 Normal and Circle
(038) STM32 UART clear transfer error flag
(039) STM32 UART Idle Callback
(040) STM32 UART, RS232 single TX line
(041) STM32 RS485 Differential signal communication
(042) STM32 HAL DMA Poll For Transfer
(043) STM32 enter low power comsuption mode
(044) STM32 Clear Flag of TCx in DMA IRQ
(045) STM32软件函数命名规范
(046) Deal with Idle in xxxCpltCallback
(047) C99 Built in macros
(048) isr enabled after calling ***_IT
(049) Procedure of starting STM32
(050) Load new firmware online
(051) SCB->VTOR
(052) STM32 Address space in programme
(053) STM32 Move program to other space
(054) STM32 Bootloader
(055) Keil中的下载算法
(056)编译器优化出错点
🍓(001) Close Swapfile
🍓(002) Format USB disk to ext4 with 1k blocks
🍓(003) Query Linux Version info and CPU info
🍓(004) Speed up latest version of Ubuntu
🍓(005) Clone 360 Browser Core Source Code Script
🍓(006) Before run Firefox in Ubuntu24.04
🍓(007) MAC Address
🍓(008) RMII & PHY
🍓(009) Ubuntu Server firewall configuration
🍓(010) Linux yield cpu by code
🍓(011) Linux Hardware Concept
🍓(012) Linux Inter-Process Communication
🍓(013) Ban Git force push
🍓(014) Ban Git reset --hard
🍓(015) Save unsaved cache to disk immedutely
🍓(016) 拷贝pre-receive到每个git仓库的脚本
🍓(017) sshd密码输入错误禁用IP3分钟
🖥️(001) 异机备份低功耗自用Git服务器搭建
🖥️(002) OpenWRT配置注意事项
🕹️(001) while(1){} cpu reentered
🕹️(002) functions for multi-thread in FreeRTOS
🕹️(003) FreeRTOS critical code zone
🕹️(004) FreeRTOS fix NULL not defined error
🕹️(005) lowest priority interrupt of ARM: PENDSV
🕹️(006) Configuration of tasks priority levels
🕹️(006) Cautions of different priority tasks locked
🕹️(008) Close scheduling of same priority tasks
🕹️(009) OTA Technology
🕹️(010) FreeRTOS create static task
🕹️(011) FreeRTOS list task list
🕹️(012) FreeRTOS HeapSize statistics
🕹️(013) FreeRTOS xTaskGetHandle
🕹️(014) FreeRTOS common method of create tasks
🕹️(015) FreeRTOS fix problem of tasks locked
🕹️(016) FreeRTOS Superest interrupt: SVC
🕹️(017) FreeRTOS interrupt call in privilege mode
🕹️(018) FreeRTOS SVC enter user mode
🕹️(019) FreeRTOS delay util
🕹️(020) FreeRTOS low consumption by Tickless
🕹️(021) FreeRTOS IdleHook
🕹️(022) FreeRTOS Hooks
🕹️(023) FreeRTOS yield CPU by code
🕹️(024) FreeRTOS semaphore
🕹️(025) FreeRTOS resolve priority inversion
🕹️(026) FreeRTOS get task priority
🕹️(027) FreeRTOS set task priority
🕹️(028) FreeRTOS function prefix
🕹️(029) Don't call RTOS function in IRQ handle
🕹️(030) Bottom half operation decrease semaphore
🕹️(031) Support Suspending for ever
🕹️(032) Call FreeRTOS SysCall in ISR
🕹️(033) Principle of Top Half and bottom haf
🕹️(034) FATFS in STM32 support exFat
🕹️(035) Message Queue in FreeRTOS
🕹️(036) Timer Tasks in FreeRTOS
🕹️(037) Reason of can not ping board
🕹️(038) LwIP Tcp Server Sample Code
🕹️(039) mutex equals binarySempahore
🕹️(040) Relationship between MEMP and Pbuf
🕹️(041) FreeRTOS连接ESP WiFi(待完成)
📟(001)CMSIS标准学习
🕹️(001)函数调用被优化
    以下为本人对流式传输的描述

    SOCKET是流式传输,阻塞模式send函数直到全部数据片段发送完成、对端存住最后的数据片段后返回;非阻塞模式只拷贝数据到socket缓冲区、缓冲区还能存多少返回值就是多少,非阻塞模式send一次的数据量不固定。

    对socket发送缓冲区中的数据进行分段地发送,每次发送就是一个TCP数据段,TCP可以单独发送请求快速处理(PUSH)和响应多个数据段的确认接收(ACK)。每个TCP段的发送都会有一次数据校验。一个数据段的大小由滑动窗口大小、最大传输单元(MTU,Maximum Transmission Unit)来确定。其中,MTU在局域网中最大就是1518字节,而在互联网中最小68字节。

    所以,TCP是流式的可靠传传输,它的每个滑动窗口、也就是每个数据段都会做奇偶校验以及得到ACK的确认。

    非阻塞模式:
    1、非阻塞模式send只是把应用层的数据拷贝进socket的内核发送缓冲区中,然后立即返回。如果IP层发送数据发生错误则会体现在下一次send调用过程中。
    2、非阻塞模式send的返回值length可能小于实际传入的数组数据的大小,因为socket内核发送缓冲区大小有限。最大只能是8k。
    3、对于接收,对端发来的数据都会经由内核接收并且缓存到socket的内核接收缓冲区之中,供应用层read方法的读取。read所做的工作,就是把内核缓冲区中的数据拷贝到应用层用户的buffer里面。所以,对于非阻塞模式的每一次read,read获得的数据量也不能确定。
    4、以上不确定长度的发送数据流和不确定长度地接收数据流只发生在物理网速特别慢、MTU特别低的时候,非阻塞send会存入部分数据到socket内核缓冲区。否则,网速足够的话、要求发送的数据内容小于MTU的话、接收端处理速度足够快的话,在发送端,缓冲区一旦有数据,数据就会被发送到对端接收端、被接受、并被送到应用层处理。
    所以,遇信号干扰、网速不够、发送缓冲区挤满,注意编程模式:要发送8k字节而实际2k字节、6k字节地发送的非阻塞流式数据传输模式。

    不论什么模式,记得:
    TCP中是数据段,UDP中是数据报文
«
--Alex.Zhang
--www.v-signon.com Learningers Co-Encouraged
Back
Personal Art: www.up-task.com Unit: Individual
中文 Русский 京ICP备19038994号-2
If the content on this website infringes upon your any rights, please contact me at 1307776259@qq.com for removal