0% found this document useful (0 votes)
102 views

Assignment 3

The document provides instructions for Assignment #3 which requires students to write a Java program that fragments IP datagrams into smaller fragments based on maximum transmission unit (MTU) sizes. The program must accept original datagram size and one or two MTU parameters. It will output the fragmented datagram sizes, offsets, and data byte ranges. Examples are provided showing fragmentation for different datagram and MTU combinations. Tips are included on parameter sizes and checking for required fragmentation. The assignment is due by April 1, 2007.

Uploaded by

hj43us
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Assignment 3

The document provides instructions for Assignment #3 which requires students to write a Java program that fragments IP datagrams into smaller fragments based on maximum transmission unit (MTU) sizes. The program must accept original datagram size and one or two MTU parameters. It will output the fragmented datagram sizes, offsets, and data byte ranges. Examples are provided showing fragmentation for different datagram and MTU combinations. Tips are included on parameter sizes and checking for required fragmentation. The assignment is due by April 1, 2007.

Uploaded by

hj43us
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment #3: IP fragmentation 

Assignment due date: Tuesday, April 1st, 2007.
As you know, IP is only allowed to deliver datagrams to the data link layer up a maximum 
size (MTU = maximum transmission unit). Larger datagrams have to be fragmented, creating 
a sequence of smaller IP datagrams also called “fragments”. 
You are required to write a Java program that will take two or three parameters:
   java IpFragmentation datagramSize MTU1 [MTU2]

Parameter datagramSize is the original datagram size, MT1 is the MTU of the first network. If 
MTU2 is provided (it is optional) it is the MTU of a second network to go through. 
Depending on the three values, zero, one or two fragmentation processes may be needed. No 
IP options are used.

Your Code
Your code has to provide an output like this:
java IpFragmentation 4440 1500 538

Fragment: DatagramSize=532 Offset=0     Data bytes from 0       to 511
Fragment: DatagramSize=532 Offset=64    Data bytes from 512     to 1023
Fragment: DatagramSize=476 Offset=128   Data bytes from 1024    to 1479
Fragment: DatagramSize=532 Offset=185   Data bytes from 1480    to 1991
Fragment: DatagramSize=532 Offset=249   Data bytes from 1992    to 2503
Fragment: DatagramSize=476 Offset=313   Data bytes from 2504    to 2959
Fragment: DatagramSize=532 Offset=370   Data bytes from 2960    to 3471
Fragment: DatagramSize=532 Offset=434   Data bytes from 3472    to 3983
Fragment: DatagramSize=456 Offset=498   Data bytes from 3984    to 4419

java IpFragmentation 4000 1500

Fragment: DatagramSize=1500 Offset=0    Data bytes from 0       to 1479
Fragment: DatagramSize=1500 Offset=185  Data bytes from 1480    to 2959
Fragment: DatagramSize=1040 Offset=370  Data bytes from 2960    to 3979

java IpFragmentation 1500 538 780

Fragment: DatagramSize=532 Offset=0     Data bytes from 0       to 511
Fragment: DatagramSize=532 Offset=64    Data bytes from 512     to 1023
Fragment: DatagramSize=476 Offset=128   Data bytes from 1024    to 1479

In the first case, a datagram of 4440 bytes will go through a network with MTU1=1500 and 
then all the resulting fragments will go through a second network with MTU2=538 (please 
note that in this latter case datagrams can only be 532 bytes long ... Do you know why?
In the second case, a datagram of 4000 bytes goes through a network with MTU=1500, which 
produces three fragments two of which are actually 1500 bytes long.
In the third case, because MTU1<MTU2, only one fragmentation process takes place. Same 
result should have obtained if we omit the MTU2 value (780).

Some tips
• Please note that the program needs to check it has at least two parameters 
(datagramSize + MTU1), if not it gives up printing a help line:
Usage: java IpFragmentation datagramSize MTU1 [MTU2]
• The value of parameter datagramSize is the total size of the original datagram, 
including IP header, expressed in bytes.
• MTU1 and MTU2 are byte units too and they may or may not suitable values for an IP 
datagram. Remember that an IP datagram may have any size (up to 64KB) but the 
“fragment offset” field on an IP datagram header counts blocks of 8 bytes. This means 
that IP fragments size may not be as large as the MTU value (as it is shown in the 
examples where MTU=538).
• IP header size is 20 bytes (provided it does not have any IP options).
• If fragmentation is not required, because datagramSize<min(MTU2,MTU1), then the 
message “Fragmentation not required” will be printed.

Due date
Your Java source code has to be submitted by email (address available on the front page) 
before April 1st 2008. 

© Miguel Sánchez 2005­2008

You might also like