The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+29 votes

In a packet switching network, packets are routed from source to destination along a single path having two intermediate nodes. If the message size is $24$ bytes and each packet contains a header of $3$ bytes, then the optimum packet size is:

  1. $4$
  2. $6$
  3. $7$
  4. $9$
asked in Computer Networks by Veteran (59.5k points)
edited by | 6.3k views

Practically, the header size of any IP packet must not be less than 20 bytes (can be observed from the IPv4 datagram format).

A similar question has been given in the NET/JRF exam 2017. The only difference is message size is 48 bytes. And the options are 1,2,4&5. So vt wud b d ans

5 Answers

+49 votes
Best answer

Correct answer should be option D.

As we know in packet switching- dividing message into packets decrease the
transmission time due to pipelined transmission.

but if there are many packets beyond some threshold then transmission time may
increase. So, we can do by option checking 

1. packet size $=4 =\text{ packet data + header size}= 1+3$

    So no. of packets will be $=\dfrac{\text{message}}{\text{packet data}}$
    $=\dfrac{24\ B}{1\ B}  = 24\text{ packets}$.

So, time to reach at receiver for $1^{st}$ packet will be,

    $=3 \text{ (source + two intermediate node)}\times \text{transmission time}$ 

$TT=\dfrac{L}{BW}$... Here, $L$ will be changed according to option and $BW$ will remain same ..

So time to reach at receiver for $1^{st}$ packet will be $=\dfrac{3\times 4}{BW}=\dfrac{12}{BW}$

and for remaining $23$ packets will take time $=23\times TT=\dfrac{23\times 4}{BW}=\dfrac{92}{BW}$

TOTAL TIME $=\dfrac{104}{BW}$

2. packet size $= 6 = 3+3\text{ ( packet data + header size)}$ so no of packets will be $8$.

Time to reach at receiver for $1^{st}$ packet will be $=\dfrac{3\times 6}{BW}=\dfrac{18}{BW}$

and for remaining $7$ packet will take time $=\dfrac{7\times 6}{BW}=\dfrac{42}{BW}$

Total time $=\dfrac{60}{BW}$

3. packet size $= 7 = 4+3,$ so no of packets $=\dfrac{24}{4}=6\text{ packets}$

For $1^{st}$ packet time will be $=\dfrac{3\times 7}{BW}=\dfrac{21}{BW}$

For remaining $5$ packet will take time $=\dfrac{5\times 7}{BW}=\dfrac{35}{BW}$

Total time$=\dfrac{56}{BW}$.

4. packet size $=9=6+3,$ so no of packet will be $4.$

For $1^{st}$ packet time will be $=\dfrac{3\times 9}{BW}=\dfrac{27}{BW}$

For remaining $3$ packets will take time $=\dfrac{3\times 9}{BW}=\dfrac{27}{BW}$

TOTAL time $=\dfrac{54}{BW}$

So, optimal packet size will be $9\text{ byte}$ due to less total transmission time.

Alternate method (thanks to sachin )

In that case we can do it using minimisation of a variable.

Let, $24\text{ byte}$ data is divided into number of packets each have $x\text{ byte}$
of data.  

Therefore, packet size $=x+3,$ and Number of packets $(k)=\dfrac{24}{x}$.
(it is ceil, if $24$ is not multiple of $x$ )

Total time =$3(x+3)+ (k-1)(x+3)$ (assumed $BW =1,$ just to avoid writing $"BW"$
again and again)

(ignoring propagation delay as it has nothing to do with packet size, if one wish
 he/she can add that too but later he will realize it will anyway become zero while differentiating. )

$\Rightarrow$ Total time $=2x+3k+kx+6$     ( $k$ is equal to $\text{24}{x}$ ) 

$\Rightarrow$ Total time $= 2x+\left(\dfrac{3\times 24}{x}\right)+\left(\dfrac{24}{x\times x}\right)+6$

$\Rightarrow$ Total time $=\dfrac{2x+72}{x+30}$

to minimise this time, diffrentiation should be $0.$ 

that gives, $2−\dfrac{72}{x^{2}} = 0$ 

$\Rightarrow x=6$.

including $3\text{ bytes}$ of header, packet size $=9\text{ Bytes}$.

Option is D.

answered by Boss (15.1k points)
edited by
why remaining 23 packets will take time = 23 *TT

why not 23*3*TT as there are (source + two intermediate node)

PLease Explain ??

@ sonam vyas Good explanation. But what if there are no options and it is numerical answer type ? :D

In that case we can do it using minimisation of a variable.

Let 24 byte data is divided into number of packets each have $x$ byte of data.  

Therefore packet size = x+3, and Number of packets (k)  =  $\frac{24}{x}$.   (it is ceil, if 24 is not multiple of x)

total time =  3(x+3)+ (k-1)(x+3)  (assumed BW =1, just to avoid writing "BW" again and again)

 (ignoring propagation delay as it has nothing to do with packet size, if one wish he/she can add that too but later he will realize it will anyway become zero while differentiating. )

$\implies$ total time =  $2x+3k+kx+6$                     (k is equal to $\frac{24}{x}$) 

$\implies$ total time =  $2x+\left (3\times\frac{24}{x} \right )+\left (\frac{24}{x} \times x \right ) +6$

$\implies$ total time =  $2x+ \frac{72}{x} +30$

to minimise this time, diffrentiation should be 0. 

that gives, $2-\frac{72}{x^2}$ = 0 $\implies x=6$

including 3 bytes of header, packet size = 9 Bytes.

Option D.

thank you sachin :) , i add this also ..
@sonam plz explain what do u mean by

" so time to reach at receiver for 1st packet will be = 3(source + two intermediate node)* transmission time"
she means since there are 2 intermediate nodes(excluding source) means u have to transmit every packet 3 times to reach for first packet it will take this much time means 3Tt..and for remaining packets only 1 Tt(simply pipelining)...
@sachin sir : i am your fan sir :)
He he...thnks for compliment :)
And i am not "sir" Just an aspirant like u :)
I am also big fan of u :D :)
@Sachin ...
Why u assumed BW=1 ..I m not getting ur reason ..
Ok, dont assume it.
U will get total time = $\frac{1}{\text{ BW }}\times  [3(x+3)+ (k-1)(x+3)]$
and at the end after diffrentiation, u will get this- $\frac{1}{\text{ BW }}\times  [2- \frac{72}{x^2}] = 0$. It wont effect anything.

By the way, u can solve same question focusing on last packet (instead of first packet)
(we know that the moment last packet reaches destination, all other packets are already reached.)

Let Number of packets (k) = $\frac{24}{x}$  (where $x$ is size of data in single packet.)
each packet size is = $x+3$

Total Bytes needs to transmitted from source = $24+3k$  ($k$ packets and each has 3 byte of header.)
Transmission time of all packets from source = $\frac{24+3k}{\text{ BW }}$  (u can take BW =1, to avoid writing it.)

Now see the time last packet takes, it got transmitted to two intermediate notes and it takes 3 propagation delay time. (of course last packet got transmitted from source also, but this time is already included in $\frac{24+3k}{\text{ BW }}$)

Time for last packet = $2 \times \text{transmission time }+3 \times \text{propagation time }$
=$2 \times \frac{x+3}{\text{ BW }}$ (ignoring propagation time)

Total time = $\frac{24+3k}{\text{ BW }} + 2 \times \frac{x+3}{\text{ BW }}$
after putting $k=\frac{24}{x}$ and differentiating wrt $x$, u will get same equation as previous which is $2-\frac{72}{x^2}=0$

Thanks;You solved my BW=1 doubt..

But according to ur next approach to deal with this question i m not getting ur below quote:-

Transmission time of all packets from source =( 24+3k) /BW

I think you are not considering here pipelining . Bcoz u r giving all load of transmission to source only.

Plz correct me !

Of course, i am considering pipeline here, just to get a shorthand calculation, I wrote directly.
U can do like this-

I want to calculate transmission time of all packets from the source.
Transmission time for one packet = $\frac{x+3}{BW}$.
there are such $k$(=$\frac{24}{x}$) packets, so toal transmission time from source = $k \times \frac{x+3}{BW}$ = $\frac{kx+3k}{BW} = \frac{24+3k}{BW}$
But it sould be preferable to write directly $\frac{24+3k}{BW}$, because i know that, this is total data that needs to transmissted from source.
Thanks Understood.

Just need confirmation of below to points.

And suppose they will give propagation time in question:-

1.If they ask abt optimal packet size then ignore it.

2.if they ask total time from source to destination then include it.

is n't it?
Yes u r right.

For 2nd statement, u can check this GATE question-

I commented there also.
Can we establish a relation here that when the data size in a packet is less in comparison to control information(header size) then such packet size will be worst as it will increase transmission time in case of option a .
yes after a thresold , header will be dominate ...
@Sachin, nice explanation!!!
$=3 \text{ (source + two intermediate node)}\times \text{transmission time}$

you should modify this line to avoid confusion to

$=3 \times \text{transmission time}$                   \\ why 3? (source + two intermediate node)
@ Sachin Mittal 1

Is it fine if I solve this by considering less headers required , by using options ?
+20 votes

option   D

packet size  $P = p+h$.  where,  $h$ is  header  size  and

$p=\sqrt{\dfrac{hx}{k-1}}$   where, $x$  is  message  size  and  $k$ is  no. of  hopes.  

so  $p=\sqrt{\dfrac{3\times 24}{2}}=\sqrt{\dfrac{72}{2}}=\sqrt{36}= 6$  

so  Optimum packet size is $ 6 + 3  =  9.$

answered by Junior (689 points)
edited by

u make it so simple...
@skrahul is this formula applicable always?
thanks ....

(k+(n-1))*(packet size)*transmission time

k is number of hops

n is number of packets.

transmission time is for one byte(unit)

so ,these method is derived from above can expand and check by yourself
where did you get this formula ?

here k=2 , so I think denominator must be 1 (as per your formula)
Is'nt bandwidth supposed to be mentioned in the formula?
+6 votes

ans given by @sonamvyas + @skrahul is right it is just my approach for generalized way for this problem
suppose x=message size, h=header size, p=payload/packet date size ,assume bandwidth is b bps,no of hopes=k 
total no of packets= x/p 
--->> when message is packetized then these are send in a pipelined manner to reduce transmission time but thereis a threshold on packet size p hence it may not be more large or more small it must be optimum (??)
  now we first derive transmission time ("ist packet takes transmissioon delay by all the intermediate nodes and source or transmission delay on all hopes and rest all packets take onle one hope transmission delay due to pipeline ")
transmission time =tt= 
         (p+h)*k / b +(x/p - 1)*(p+h)/b
=1/b( (p+h)*k + 1/p (x-p) (h+p))
// so resultantely we want to find minimum transmission delay at optimum packet size so differentiate tt w.r.t. p we get  //
dtt/dp= 1/b(k*p-p2-xh)=0
so p=(xh/k-1) or p=√(xh/k-1)
here h=3 x=24 k=3
p=√(24*3)/2 =6
so packet size =p+h=6+3=9 bytes

answered by Boss (12.3k points)
Can you provide some refrence to above derivation. Is it given in some book?
@abcd2 i have no reference for it ....
is here any doubt u can telll me .......
Please write it in a neat manner. Bit difficult to understand..
+4 votes

i have formal approach to solve this problem

answered by Active (3.1k points)
+2 votes

Dividing a message into packets may decrease the transmission time due to parallelism as shown in the following figure. But after a certain limit reducing the packet size may increase the transmission time also. Following figure shows the situation given in question. Let transmission time to transfer 1 byte for all nodes be t. The first packet will take time = (packet size)*3*t. After the first packet reaches the destination, remaining packets will take time equal to (packet size)*t due to parallelism.

If we use 4 bytes as packet size, there will be 24 packets
Total Transmission time = Time taken by first packet + 
                          Time taken by remaining packets 
                       = 3*4*t + 23*4*t = 104t

If we use 6 bytes as packet size, there will be 8 packets
Total Transmission time = 3*6*t + 7*6*t = 60t

If we use 7 bytes as packet size, there will be 6 packets
Total Transmission time = 3*7*t + 5*7*t = 56t

If we use 9 bytes as packet size, there will be 4 packets
Total Transmission time = 3*9*t + 3*9*t = 54t
answered by Loyal (8.8k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

38,040 questions
45,537 answers
48,853 users