필터 지우기
필터 지우기

how to calculate number of byte send in UDP

조회 수: 5 (최근 30일)
rps rathore
rps rathore 2015년 8월 14일
댓글: rps rathore 2015년 8월 21일
i send data in udp call.
u = udp('127.0.0.1', 8000);
fopen(u);
x = (0:999) .* 8 * pi / 1000;
data = sin(x);
fwrite(u, data, 'float32');
how many byte is sent in this fwrite call.
how to calculate byte using this call
please explain
similarly
fread(u, datas, 'float32');
how many byte is received in this fread call.
how to calculate byte using this call
thanks
  댓글 수: 1
rps rathore
rps rathore 2015년 8월 14일
thanks for replying. how many bytes is taken by object u also. how many total bytes including data plus u

댓글을 달려면 로그인하십시오.

답변 (2개)

Uladzimir
Uladzimir 2015년 8월 14일
fwrite(u, data, 'float32') Here are numel(data)*4 bytes.
fread(u, datas, 'float32') Here are datas*4 bytes

Walter Roberson
Walter Roberson 2015년 8월 14일
udp takes 2*32 bits = 8 bytes, plus the length of the data (which here would be 4 bytes). But udp packets have to be embedded in IP packets, which take 5*32 bits = 20 bytes before the UDP packet.
But IP packets have to be embedded in a physical transport layer such as ethernet which require a number of bytes around the IP packet. The structure of Wi-Fi 802.11 packets is not the same as for Ethernet; more at http://www.wildpackets.com/resources/compendium/wireless_lan/wlan_packets#wp1000999
You need to decide on a particular physical transmission standard, and you need to decide what you want to include in your count. Do you count the preamble (historically it was allowed for some of the bytes to go missing in transit)? The Frame Check Sequence (a lot of people forget but it really should be included)? The Interpacket Gap (arguable, since it is a mandatory gap in transmission rather than data being transmitted)

카테고리

Help CenterFile Exchange에서 Gas Dynamics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by