Jump to content

Isolating sections of a Datagram

- - - - -

  • Please log in to reply
20 replies to this topic

#1
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I'm working on a project for a networking course at the university i attend. We are supposed to write an app than works like a gateway for ipv4 datagram packets to be repackaged to ipv6 datagram packets(should be in java).My initial thinking was: Use java get methods to pull apart the datagram, then construct a new datagram packet(making whatever changes necessary) using the data we pulled from the ipv4 packet.
What we have access to via the Datagrampacket class methods are data, address, length, offset and port. Which means we dont get the juicy stuff like version, header length, type of service, identifier etc. Additionally it seems there is no constructor in this class to create a datagram packet given we manage to extract the required feilds.
Basically i'm looking for a bit of direction from this point.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#2
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
;). I need some help guys. still a bit lost
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#3
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
Since Java classes does not include methods to isolate each section of a datagrampackdt. I'm thinking now since a datagram is made up of bits, if it would be feasible to develop a class to separate the packet into sequential bits. Taught: i should be able to reassemble each section individually.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
I'm not really into network programming, but what would happen if you change the ipv4 address into an ipv6 one of the DatagramPacket class? (packet.setAddress(Inet6Address.getByName(host) )
I know the header of a ipv4 and ipv6 packet differ.. but i hope that since you can't get or set those with methods the class has some built in features to adapt those to the address that's given.

.. is there an easy way to test this kind of stuff?

#5
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I am doing a lot of googling and i've just started reading the rfc's. But i didn't find anything to test thus far.

packet.setAddress(Inet6Address.getByName(host) )
would set the IP address of the machine to which this datagram is being sent.
this is how the ipv4 datagram looks

The IP datagram structure.

I need to extract every field, then construct an ipv6 packet

What i've done so far is break the datagram into bits. But i suspect corruption or alteration of the bits particulary with toString() . I would post the code in a while with hope than the java guru's on codecall could help with the tidying up.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#6
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
I'm having examn tomorrow and friday, but after that i got a whole week to freak out on this :D
I found this book on google books which seems to be quite interesting.
At page 426 it also says that with pure Java code you can't access the header fields apart from source, destination, port, data, length of data.
So it'll either has to work with the bit splitting, or else you need an external library

Java network programming - Google Books

#7
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I think an external library would do the trick, if such is available. And another thing: after the packet is broken down to bits , if we manage to read the data correctly i have to construct an ipv6 packet from that data. Really tired!:crying:

Question: when i make a packet with java using one of the constructors, is there a way to tell if its an ipv4 or ipv6?
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#8
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
I actually still believe in the fact that changing the InetAdress will be enough and Java takes care of anything else ^^

#9
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
Im giving it some taught. I will post something back very soon.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#10
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I have a few midterm exams on my chest today and tomorrow. Once i done ill jump back in :)
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#11
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
Given the deadline for submission, my lecturer is allowing me to do a simulation of the conversion instead of the actual conversion. So I'm thinking of building a GUI application thats show the transition from ipv4 to ipv6.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#12
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
So you just have to visualise the ipv4 header and move the parts of the header into a new ipv6 header? O.0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users