In Bluetooth Low Energy 4.0 and 4.1, the max PDU of an OTA packet is 39 bytes (47 bytes with preamble, access address and CRC) and was increased to 257 bytes in version 4.2.
The reason of short packet is stability of the radio, long packets heat up the silicon and extra circuitry to be added to keep the frequency stable.So, in BLE 4.1, the longest possible packet is 376 microseconds to avoid heating effect. As the data rate is 1Mhz, 376 microseconds is 376 bits = 47 bytes so the size of PDU is explained. But in the version 4.2, the longest packet is 2120 bits, so 2.12ms and I read 3ms packets in bluetooth classic are long enough to cause problems. So my question is: Why and how did SIG succeed to increase the PDU in version 4.2 know some semiconductor companies state the hardware is the same for all the versions. What did lead to this new PDU length?
In 4.[01], 39 bytes is the maximum LL PDU size reached for advertisement packets (2 bytes of header, 6 bytes of device address, 31 bytes of AD).
For data packets, max PDU size is 33 bytes (2 Header + 4 L2CAP + 23 ATT + 4 MIC).
Note Data channel header counts the PDU size without the header, so this makes the data channel payload size go up to 31 bytes. This is the number that got enlarged in 4.2 (the actual minimal value is 27 bytes if crypto is not supported, because 4-byte MIC will never appear in the packet).
The new data channel payload size defined in 4.2 is the maximum possible value protocol can support, so it's a value a chip may support rather than an absolute packet size every chip must support.
Actual data channel payload size is negotiated with LL_LENGTH_REQ and LL_LENGTH_RSP between the two involved radios. They may negotiate any length from 27 up to 251 bytes (at the payload level) (See Core_v4.2 6.B.2.4.2.21).
In first release of the BLE spec, packet absolute max size was 27 bytes (data payload, without MIC). Spec used a 5-bit field for LL packet size, 3 other bits of this header byte were RFU. It eventually got enlarged to 8-bit with full backward compatibility in 4.2, but there are no more contiguous bit available in the header. To me, this explains why limit is around 256 bytes (give or take because of fixed header sizes that are not part of the byte count): it gives a reasonable extension without changing the protocol much.
Related
By IEEE 802.3, an Ethernet frame has to carry a payload of at least 46 bytes. This is for collision detection-- collisions of smaller frames (may) go undetected.
The Q is: what if the payload to be carried is shorter? what kind of padding is used to scale the frame up to the slot size-- 64 bytes?
TIA.
To quote from Data and Computer Network Communication (emphasis mine);
If the network layer wishes to send less than 46 bytes of data the MAC protocol adds sufficient number of zero bytes (0x00, is also known as null padding characters) to satisfy the requirement.
Some buggy drivers fail to do this though as noted by Adaptec.
I have data 1245 MB for trasmission via UDP over IPv4.
For calculation of expected number of packet transmission from A to B then B relay to C, if the data transmitted in blocks of size 320bytes (i.e; payload = 320bytes), and header is 20 bytes, do we minus 20 from 320 or add in?
For instance,
1245MB = 1305477120 bytes
Total UDP Payload = 320 - 20 or 320 + 20?
The packet consists of:
the IP header (20 bytes)
the UDP header (8 bytes)
your payload (320 bytes).
Total: 348 bytes.
For calculating the number of packets you don't need to take into account the size of the transport or network layer headers. You specified a payload size of 320 bytes, which is well within the maximum size of a UDP payload without fragmentation.
Each time you call send() or sendto(), this will create a datagram (packet), so the math is simply dividing the total size by your 320 byte chunks:
1305477120 / 320 = 4079616 packets
As a side point, if you were to make your UDP payload larger, that would reduce the total number of packets. On a lot of networks, the MTU is 1500 bytes, so you can send:
1500 bytes - IP header (20 bytes) - UDP header (8) bytes = 1472 bytes for payload
As a second side point, if your UDP payload is too big, i.e. payload + IP/UDP headers exceeds the MTU, then your single call to send() would result in multiple IP fragment packets.
I am currently going through my networking slides and was wondering if someone could help me with the concept of fragmentation and reassembly.
I understand how it works, namely how datagrams are split into smaller chunks because network links have a MTU. However the example in the picture is confusing me.
So the first two sections show a length of 1500, because this is the MSU, but shouldn't this mean that the last one should have 1000 (for a total of 4000 bytes) and not 1040? Where did these extra 40 bytes come from? My guess is that because the previous two fragments both had a header of 20 bytes, this extra 40 bytes of data needed to go somewhere, so it will arrive in the last fragment?
Fragflag essentially means that there is another fragment, so all of them will have a Fragflag of 1 except the last fragment which will be at zero. However I don't understand what offset is or how it is calculated. Why is the first offset at zero? Why did we divide the bytes in the datafield (1480) by 8 to get the second offset? Where did this 8 come from? Aside from that, I am assuming that each fragments offset will just increase by this value?
For example, the first fragment will have a offset of 0, the second 185, the third 370 and the fourth 555? (370+185)
Thanks for any help!
There is a 20 byte header in each packet. So the original packet contains 3,980 bytes of data. The fragments contain 1480, 1480, and 1020 bytes of data. 1480 + 1480 + 1020 = 3980
Every bit in the header is precious. Dividing the offset by 8 allows it to fit in 13 bits instead of 16. This means every packet but the last must contain a number of data bytes that is a multiple of 8, which isn't a problem.
The fragmentation and Reassembly has been exclusively explained in the RFC 791. Do go through the Internet Protocol Specification RFC. The RFC has various sections explaining the sample fragmentation and reassembly. All your doubts and questions are well catered in it.
Ans 1: Regarding the lengths of the packet: The original Packet contains 4000 Bytes. This packet is a fully IP packet and hence contains the IP header as well . Thus the payload length is actually 4000 - ( IP Header Length i. e. 20 ).
Actual Payload Length = 4000 - 20 = 3980
Now the packet is fragmented owing to the fact that the length is greater than the MTU ( 1500 Bytes).
Thus the 1st packet contains 1500 Bytes which includes IP header + Payload Fraction.
1500 = 20 ( IP header ) + 1480 ( Data Payload )
Similarly for the other packet.
The third packet shall contain remaining left over data ( 3980 - 1480 -1480 ) = 1020
Thus length of the packet is 20 ( IP Header ) + 1020 ( payload ) = 1040
Ans 2: The offset is the address or the locator from where the data starts with reference to the original data payload. For IP the data payload comprises all the data thats after the IP header and Options header. Thus the system/router takes the payload and divides it into smaller parts and keeps the track of the offset with reference to the original packet so that reassembly can be done.
As given in the RFC Page 12.
"The fragment offset field tells the receiver the position of a fragment in the original datagram. The fragment offset and length determine the portion of the original datagram
covered by this fragment. The more-fragments flag indicates (by being reset) the last fragment. These fields provide sufficient information to reassemble datagrams. "
The fragment offset is measured in Units of 8 bytes each. It has 13 bit field in the IP header. As said in the RFC page 17
"This field indicates where in the datagram this fragment belongs.The fragment offset is measured in units of 8 octets (64 bits). The first fragment has offset zero."
Thus as you asked in the question where did this 8 come from, its the standard thats been defined for IP protocol specification, where 8 octets are taken as one value. This also helps us to transmit large packets via this.
Page 28 of the RFC writes:
*Fragments are counted in units of 8 octets. The fragmentation strategy is designed so than an unfragmented datagram has all zero fragmentation information (MF = 0, fragment offset =
0). If an internet datagram is fragmented, its data portion must be
broken on 8 octet boundaries. This format allows 2**13 = 8192 fragments of 8 octets each for a
total of 65,536 octets. Note that this is consistent with the the
datagram total length field (of course, the header is counted in the
total length and not in the fragments).*
the offset size is 13 bits in the IP header but we need 16 bits as in worst case. So we use a scaling factor of 8 i.e. (2^16/2^13).
those are not extra bits but the total length of last fragment.
as 1500 is MTU this means there can be 1500 byte of data in one fragment including header. Header is appended with every fragment. this means in fragment we are capable of sending 1500-20 =1480 byte of data.
it is given there is 4000B datagram .datagram is nothing but a packet encapsulation of data at network layer.so the total data we have to send is 4000-20=3980 . then it is fragmented into 3parts (ceil(3980/1480)) each of length 1480,1480,1020 respectively . hence when 20B header is appended to last fragment its length becomes 1020+20=1040 .
What is the size of an empty UDP datagram? And that of an empty TCP packet?
I can only find info about the MTU, but I want to know what is the "base" size of these, in order to estimate bandwidth consumption for protocols on top of them.
TCP:
Size of Ethernet frame - 24 Bytes
Size of IPv4 Header (without any options) - 20 bytes
Size of TCP Header (without any options) - 20 Bytes
Total size of an Ethernet Frame carrying an IP Packet with an empty TCP Segment - 24 + 20 + 20 = 64 bytes
UDP:
Size of Ethernet frame - 24 Bytes
Size of IPv4 Header (without any options) - 20 bytes
Size of UDP header - 8 bytes
Total size of an Ethernet Frame carrying an IP Packet with an empty UDP Datagram - 24 + 20 + 8 = 52 bytes
Himanshus answer is perfectly correct.
What might be misleading when looking at the structure of an Ethernet frame [see further reading], is that without payload the minimum size of an Ethernet frame would be 18 bytes: Dst Mac(6) + Src Mac(6) + Length (2) + Fcs(4), adding minimum size of IPv4 (20) and TCP (20) gives us a total of 58 bytes.
What has not been mentioned yet is that the minimum payload of an ethernet frame is 46 byte, so the 20+20 byte from the IPv4 an TCP are not enough payload! This means that 6 bytes have to be padded, thats where the total of 64 bytes is coming from.
18(min. Ethernet "header" fields) + 6(padding) + 20(IPv4) + 20(TCP) = 64 bytes
Hope this clears things up a little.
Further Reading:
Ethernet_frame
Ethernet
See User Datagram Protocol. The UDP Header is 8 Bytes (64 bits) long.
The mimimum size of the bare TCP header is 5 words (32bit word), while the maximum size of a TCP header is 15 words.
Best wishes,
Fabian
If you intend to calculate the bandwidth consumption and relate them to the maximum rate of your network (like 1Gb/s or 10Gb/s), it is necessary, as pointed out by Useless, to add the Ethernet framing overhead at layer 1 to the numbers calculated by Felix and others, namely
7 bytes preamble
1 byte start-of-frame delimiter
12 bytes interpacket gap
i.e. a total of 20 more bytes consumed per packet.
If you're looking for a software perspective (after all, Stack Overflow is for software questions) then the frame does not include the FCS, padding, and framing symbol overhead, and the answer is 54:
14 bytes L2 header
20 bytes L3 header
20 bytes L4 header
This occurs in the case of a TCP ack packet, as ack packets have no L4 options.
As for FCS, padding, framing symbol, tunneling, etc. that hardware and intermediate routers generally hide from host software... Software really only cares about the additional overheads because of their effect on throughput. As the other answers note, FCS adds 4 bytes to the frame, making it frame 58 bytes. Therefore 6 bytes of padding are required to reach the minimum frame size of 64 bytes. The Ethernet controller adds an additional 20 bytes of framing symbols, meaning that a packet takes a minimum of 84 byte times (or 672 bit times) on the wire. So, for example, a 1Gbps link can send one packet every 672ns, corresponding to a max packet rate of roughly 1.5MHz. Also, intermediate routers can add various tags and tunnel headers that further increase the minimum TCP packet size at points inside the network (especially in public network backbones).
However, given that software is probably sharing bandwidth with other software, it is reasonable to assume that this question is not asking about total wire bandwidth, but rather how many bytes does the host software need to generate. The host relies on the Ethernet controller (for example this 10Mbps one or this 100Gbps one) to add FCS, padding, and framing symbols, and relies on routers to add tags and tunnels (A virtualization-offload controller, such as in the second link, has an integrated tunnel engine. Older controllers rely on a separate router box). Therefore the minimum TCP packet generated by the host software is 54 bytes.
What is the overhead for PPP and Ethernet sending 5000 bytes?
Frame size for Point-to-Point Protocol: 8 bytes
MTU: 500 bytes
Frame size for Ethernet: 18 bytes
MTU: 1500 bytes
Both sending 5000 bytes..
I know this is just a calculation, but I am not sure how to do it. I can't find it anywhere. I would think that since a PPP frame takes 8 bytes and maximum transmission unit is 500 then it can send (500 - 8)bytes of information in one go. It sends 10 frames, resulting in 4920 bytes sent. Then sends the final (80+8)bytes with the last frame.
Similar for Ethernet. (1500 - 18)bytes with each frame. 3 frames sent means 4446 bytes sent. Sending (554+18)bytes in the last frame.
This obviously doesn't answer the "overhead" question. Anyone have any ideas?
It really depends on how you define overhead. This answer will assume overhead is the number of bytes that you need to transmit in addition to the data itself.
For Ethernet, assuming the 5000 byte payload is not encapsulated in an IP + TCP/UDP frame, you will have 18 bytes of overhead for every packet sent. That means each transmission with an MTU of 1500 will be able to hold 1482 bytes. To transmit 5000 bytes, this means 4 packets must be transmitted, which means an overhead of 72 bytes (18 * 4). Note that the overhead becomes bigger when you include things like the IP frame which contains a TCP frame.
For PPP, as you've already shown, you can send 492 bytes per frame. Eleven frames means 88 bytes of overhead (11 * 8) - again, not including any additional protocol frames within the payload.
In both these examples any protocols that build on top of these link layer protocols will contribute to overhead. For example, an Ethernet packet sent with an IPv4 frame which contains a UDP datagram will have an additional 28 bytes consumed by headers and not data (20 bytes in an IPv4 header and 8 in a UDP header, assuming no IP options). Considering the original Ethernet example, this means the amount of data per packet becomes 1454 bytes, which luckily still comes to 4 packets (the extra spills over into the smaller 4th packet), with 144 bytes of overhead.
You can read more here (I find that page a little hard to read though).