minimum lenght of UDP data ...?

This is a discussion on minimum lenght of UDP data ...? within the Networking/Device Communication forums, part of the General Programming Boards category; Hello . I read a book about ethernet and it has been written in it " for recognition of collision ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    177

    minimum lenght of UDP data ...?

    Hello .
    I read a book about ethernet and it has been written in it " for recognition of collision the minimum No. of UDP data must be 46 bytes" .
    I have also a program that sends UDP packet to ethernet but the data field has 3 bytes data and 17 bytes padding .
    can you plz tell me
    what is the minimum lenght of UDP data (data + padding) in an ethernet whitch uses Type instead of type/lenght field ?

    thank you

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    134
    Not sure what you are trying to ask. Ethernet header's type field tell about the upper layer protocol which layer 3. For e.g. 0x0800 for IPv4. Its never UDP. IP header contains L4 protocol field which tells about the Layer 4 protocol like ,17 for UDP and 6 for TCP.

    Ethernet header has no info about Layer 4 protocol.

    Collision at layer 2 happens when 2 or more hosts try to send the data at the same time.

    Here is a short paragraph from this book Lan Switching by Kennedy Clark.

    Ethernet rules state that a station must detect and report collisions between the furthest points in the network before the source completes its frame transmission. Specifically, for a legacy 10 Mbps Ethernet, this must all occur within 51.2 microseconds. Why 51.2 microseconds? The time is based on the smallest frame size for Ethernet, which corresponds to the smallest time window to detect and report collisions. The minimum frame size for Ethernet is 64 bytes, which has 512 bits. Each bit time is 0.1 microseconds in length, which is calculated from one over Ethernet's data rate (1/106). Therefore, the slot time for Ethernet is 0.1 microseconds/bit x 512 bits or 51.2 microseconds.

    A network that violates the slotTime rules by extending the network to distances that require more than 51.2 microseconds experience late collisions, which can cause the network to malfunction. When a station transmits, it retains the frame in a local buffer until it either transmits the frame successfully (that is, without a collision) or the deferral counter threshold is exceeded. We previously discussed the deferral counter situation. Assume that a network administrator overextends the network in Figure 1-3 by inserting too many repeaters or by deploying segments that are too long. When Station 1 transmits, it assumes that the frame successfully transmitted if it experiences no collision by the time that it transmits 64 octets. Once the frame believes that it was successfully transmitted, the frame is eliminated from buffers leaving no opportunity to retry. When the network overextends the slotTime, the source might learn of a collision after it transmits the first 64 octets. But no frame is in the buffer at this point to resend, because the source thought that the transmission was successful!

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    stations needs a minimum time for recognition of collision , it is why we use padding and the lentgh of data field must be at least (??) bytes .

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    It is what has been written in the link below:
    http://en.wikipedia.org/wiki/User_Datagram_Protocol

    "Length is the length in octets of this user datagram including this
    header and the data.(This means the minimum value of the length is
    eight.)"
    then a UDP packet can have no data (cause UDP header has 8 bytes) , is it true ?
    if yes , why padding is used ?can't we just put data in data field ?

  5. #5
    Registered User
    Join Date
    Apr 2005
    Posts
    134
    ok in that case, as per my last post and "linux/if_ether.h" file on my linux host, size should be minimum 60-64 bytes for an end station to successfully detect the collision. But you don't really have to worry about padding the packet, if it is less than minimum reqd. bytes. This is taken care of in your network interface's device driver. If it detect the final data length to be transmitted on the media is less than the minimum data length, it pads the remaining buffer with 0s to make it minimum bytes length.

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    I am working on an AVR microcontroller to connect it to ethernet .
    I did ARP and PING successfully and starting to send UDP packet , it is why I am worry about NO. of paddidg .
    I have to make a right packet in the AVR memory then sending it to ethernet .

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    134
    Quote Originally Posted by arian
    It is what has been written in the link below:
    http://en.wikipedia.org/wiki/User_Datagram_Protocol

    "Length is the length in octets of this user datagram including this
    header and the data.(This means the minimum value of the length is
    eight.)"
    then a UDP packet can have no data (cause UDP header has 8 bytes) , is it true ?
    if yes , why padding is used ?can't we just put data in data field ?
    Like I said, Padding happens at device driver level, while UDP data is stuffed above transport layer. A UDP packet may contain no data (just the header). In that case your final datagram as seen by the network driver will have length as below

    ethernet_header(14 bytes) + IPv4_header(20 bytes min) + UDP_header (8 bytes) = 42 bytes

    Now since its less than the 64 bytes (or 60 as per by linux host), network driver will pad the packet with (64-42 = 22 ) zeros to make it 60 bytes before its sent out the packet over wire.
    Last edited by nkhambal; 08-08-2005 at 04:12 AM.

  8. #8
    Registered User
    Join Date
    Apr 2005
    Posts
    134
    Quote Originally Posted by arian
    I am working on an AVR microcontroller to connect it to ethernet .
    I did ARP and PING successfully and starting to send UDP packet , it is why I am worry about NO. of paddidg .
    I have to make a right packet in the AVR memory then sending it to ethernet .
    Padding should be taken care of by the network driver. Applications should not be burdened with the padding and data alignment.

  9. #9
    Registered User
    Join Date
    Nov 2003
    Posts
    177
    I will test what you said , thanks .
    I have an AVR microcontroller and an Ethernet controller(RTL8019as) that is conencted to RJ-45 on my board . then a cable that conects this RJ-45 to my PC NIC .
    do you mean I just put the data in the packet I am going to send and there is no need for padding?
    then send the packet from AVR to RTL8019as ?
    I cant find any part in RTL8019as datasheet that talk about autamatic padding .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with UDP
    By AlexS in forum C# Programming
    Replies: 0
    Last Post: 07-07-2009, 06:21 PM
  2. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 07:04 PM
  3. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  4. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 08:09 PM
  5. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 02:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21