| < Day Day Up > |
|
The open source for TCP/IP protocol stack is available with the Linux operating system.
The Java code for implementation of UDP server and UDP client are given in Listing C.6 and Listing C.7, respectively. The server software is used to transfer a file to the client. The server divides the file into UDP datagrams and sends it. The client will receive each datagram and assemble the file. This code can be tested on a LAN environment.
Listing C.6: UDP server software.
import java.net.*; public class UDPServer { public static DatagramSocket ds; public static int buffer_size=10; public static int serverport=555; public static int clientport=444; public static byte buffer[]=new byte[buffer_size]; public static void Server() throws Exception { int pos=0; byte b[] = { 'H','e','l','l','o'}; ds.send(new DatagramPacket (b, b.length, InetAddress.getLocalHost(), clientport)); } public static void main(String args[]) { try{ System.out.println("Server is ready"); ds=new DatagramSocket(serverport); Server(); }catch(Exception e){ } } }
Listing C.7: UDP Client software.
import java.net.*; public class UDPClient { public static DatagramSocket ds; public static int buffer_size=5; public static int serverport=555; public static int clientport=444; public static byte buffer[]=new byte[buffer_size]; public static void Client() throws Exception { while(true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); ds.receive(dp); byte b[] = dp.getData(); for(int i=0;i<=b.length;i++) System.out.print((char)b[i] + " "); } } public static void main(String args[]) { try{ System.out.println("Client is ready"); ds=new DatagramSocket(clientport); Client(); }catch(Exception e){ } } }
In sliding window protocol used in TCP, the receiver must advertise its window size. Receiver may advertise a small window size due to various reasons such as buffer full. In such a case, the sender has to transmit small segments. This results in inefficient utilization of the bandwidth. To avoid this problem, the receiver may delay advertising a new window size, or the sender may delay sending the data when the window size is small.
In a satellite communication system, if the VSATs are receive only, it is not possible for VSAT to send an acknowledgement to the server located at the hub. In such a case, the server at the hub has to use the UDP as the transport layer to transmit the file. The server software will divide the file into UDP segments and broadcast each datagram. The datagram contains the VSAT address as the destination address. The VSAT will receive the datagarams and assemble the file.
In sliding window protocol used in the TCP layer, the receiver has to advertise the window size, and the sender must adhere to this size. This may cause the silly window syndrome.
| < Day Day Up > |
|