2

From what I understand, store and forward works on the principle of storing bits of packets until the whole packet is received and then transmitting them. Also, bits are made to wait in a queue before transmission. Since a router receives multiple packets at the same time, how are the bits of packets arranged in a queue so as to not mix with other packets? Is there a queue of queues?

3
  • Packets have headers that either have an explicit packet length in the header, or it is known how to calculate the packet size from information in the header. The router reads the packet header and dequeues the correct number of bits to get one entire packet to send.
    – Ron Maupin
    Jul 28, 2018 at 15:36
  • @RonMaupin Thanks for the reply! Although it's 3 lines it cleared stuff up for me! Jul 28, 2018 at 20:18
  • I posted an answer for you that gives you some more context.
    – Ron Maupin
    Jul 28, 2018 at 22:12

3 Answers 3

2

Packets have headers that either have an explicit packet size, e.g. the IPv4 header Total Length Field, or enough information to calculate the packet size, e.g. the IPv6 Payload length field.

For IPv4, there is RFC 791, Internet Protocol:

3.1. Internet Header Format

A summary of the contents of the internet header follows:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                 Example Internet Datagram Header

For IPv6, there is RFC 2460, Internet Protocol, Version 6 (IPv6) Specification:

  1. IPv6 Header Format

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |Version| Traffic Class |           Flow Label                  |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  
    |         Payload Length        |  Next Header  |   Hop Limit   |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +                                                               +
    |                                                               |
    +                         Source Address                        +
    |                                                               |
    +                                                               +
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    +                                                               +
    |                                                               |
    +                      Destination Address                      +
    |                                                               |
    +                                                               +
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    

Of course, there are/have been other network protocols, but each has something similar.

After a packet is enqueued, it can be dequeued by the router in its entirety, without grabbing bits from other packets because the packet size is known, and only the bits for the packet to be dequeued are removed from the queue and forwarded. This means that different packets in the queue can all be different sizes, and the router will not get but what it needs for a packet, and it will get the entire packet.

2
  • Thanks a lot for the answer! The header diagram really cleared up other stuff too. I read that RFCs are usually very technical, so is it a usable source of reference for a novice like me? Jul 31, 2018 at 16:12
  • The RFCs are the definitions of the protocols. Even novices can gain something by reading the RFCs, even if they don't completely understand, and as understanding grows, then reread the RFCs. This is an iterative process. It is important to be able to read and understand the RFCs, and compare them to other resources you may find. Also, be aware that many RFCs have been updated by other RFCs, and some RFCs are obsolete. That will be explained in the RFC headers.
    – Ron Maupin
    Jul 31, 2018 at 16:18
2

The bits are organized in packets and it's up to the discretion of the router to queue and unqueue those packets neatly and without mixing anything up.

Receiving multiple packets from different interfaces is absolutely common but (usually) each packet is passed to the egress queue in a single, atomic operation once it's been received in entirety.

0

There isn't just a single queue, there are queues per interface, so there isn't any intermingling of the bits in different packets. The packets are stored in the queues as entire packets, with an internal header to hold information such as source interface, VLAN etc. The packets are referenced through pointers to the data that the OS can then use to forward the packet to an egress queue. Sometimes shared buffers are used, which are shared between many interfaces, but again, the packets are stored as whole packets (with headers) and the device keeps track of them through pointers. At the end of the day a queue is just a block of memory that the OS manages.

2
  • Thanks a lot for answering! I do still have a few doubts though. Could you elaborate on the phrase 'queues per interface' ? Jul 28, 2018 at 19:28
  • There are seperate queues for each interface. There can also be multiple queues for the same interface. The interface can classify traffic by looking at a CoS/QoS label or by looking at other header information and assign it to a queue. The interface can then service the queues and give a preference to certain types of traffic. Usually voice is given preference.
    – user27899
    Jul 28, 2018 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.