0

I am building a TFTP(RC1350) application using Java. So far I have been able to make the successful transfers between two different computers whether its for a read request or a write request. As the RC1350 specification suggests, I specify the destination address and the port number by putting this information into a DatagramPacket.

Based on RC1350, the order of headers is the following:

      ---------------------------------------------------
     |  Local Medium  |  Internet  |  Datagram  |  TFTP  |
      ---------------------------------------------------

                  Figure 3-1: Order of Headers

And it also states "TFTP DOES NOT specify any of the values in the Internet header".

Since my TFTP application does not touch the IP header at all, than how does IP determine what to put as an address into an IP header?

Haris Ghauri
  • 547
  • 2
  • 7
  • 27

1 Answers1

1

TFTP doesn't specify what's in the IP header, but that doesn't mean there's nothing in there.

UDP puts the source and destination ports in the UDP header, and IP puts the source and destination addresses in the IP header.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
user207421
  • 305,947
  • 44
  • 307
  • 483
  • UDP puts source and destination information into an IP header? – Haris Ghauri May 13 '16 at 00:10
  • "IP puts source and destination address into the IP header" How does IP decide what to put as an address into the IP header? Where does it get that info from? – Haris Ghauri May 13 '16 at 01:44
  • 1
    Well IP knows the source address (and UDP knows the source port). The destination address:port comes from the application. Specifically, from the `sendto()` method, or the `connect()` method if the socket has been connected. – user207421 May 13 '16 at 01:58
  • So you are saying, when i invoke send method on DatagramSocket and pass DatagramPacket into its parameters, behind the scenes, the information of the IP address(destination) is actually extracted from the DatagramPacket and put into the IP header. – Haris Ghauri May 13 '16 at 02:07
  • 1
    To be precise: Java extracts the destination address from the `DatagramPacket` and passes it to `sendto()`. `sendto()` passes it to the operating system. UDP uses the port in the UDP header, and IP uses the address in the IP header. That's why this information is in the `DatagramPacket` in the first place. – user207421 May 13 '16 at 02:20
  • 1
    Yes that was the my main question. I wanted to know how does source and destination IP addresses are actually moved to IP header. But you explained it very well. Thank you :) – Haris Ghauri May 13 '16 at 02:25