edu.rit.m2mp.udp
Class UDPChannel
java.lang.Object
edu.rit.m2mp.Channel
edu.rit.m2mp.udp.UDPChannel
- Direct Known Subclasses:
- UDPMulticastChannel, UDPUnicastChannel
public abstract class UDPChannel
- extends Channel
Class UDPChannel is the abstract base class for an M2MP
Channel
that uses UDP datagrams to
transport M2MP packets. Two subclasses are provided:
-
Class
UDPMulticastChannel
is a
broadcast channel that sends each UDP datagram to an IP multicast address and
port number. Thus, all hosts that are using a UDPMulticastChannel with the
same IP multicast address and port number receive the M2MP packets.
-
Class
UDPUnicastChannel
is a
point-to-point channel that sends each UDP datagram to one host at a certain
IP address and port number. Thus, a UDPUnicastChannel provides an M2MP
"tunnel" between two hosts.
The following parameters from the M2MP properties file are used to configure
a UDPChannel. Subclasses may use additional configuration parameters. See
class
M2MPProperties
for
further information.
-
edu.rit.m2mp.udp.address
The IP address to use for sending outgoing UDP datagrams. If this property is
not specified, a subclass-specific default IP address is used.
-
edu.rit.m2mp.udp.port
The port number to use for sending outgoing UDP datagrams. It must be a
decimal integer. If this property is not specified, a default port number of
5678 is used.
-
edu.rit.m2mp.udp.localaddress
The IP address of this host; specifically, the local IP address to which to
bind the datagram mailbox. This parameter is needed in case this host has
multiple IP addresses (multiple network interfaces). If this property is
specified, it may be one of the following:
-
The name of one of this host's network interfaces (like "eth0",
"eth1", etc.). The IP address of that network interface is used.
-
The host name of this host (corresponding to one of this host's network
interfaces).
-
The IP address of this host (corresponding to one of this host's network
interfaces).
If this property is not specified, the channel tries to determine the host's
IP address automatically, as follows. The channel finds all the network
interfaces, examines all their IP addresses, and picks the first IP address
that does not begin with 127. (IP addresses that begin with 127 are
"loopback" addresses that do not communicate outside the host.) This usually
works on a host with one network interface. If there are two or more network
interfaces, the channel picks one of them in an unspecified manner. If the
channel cannot find an IP address, it throws an exception, causing the M2MP
Layer initialization to fail.
-
edu.rit.m2mp.udp.localport
The port number to use on this host; specifically, the local port number to
which to bind the datagram mailbox. It must be a decimal integer. If this
property is not specified, a default port number of 5678 is used.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UDPChannel
public UDPChannel(PacketPool thePacketPool,
String theDefaultAddress)
- Construct a new UDP channel. To receive incoming packets, the channel
implementation will obtain
Packet
objects from the given
PacketPool
.
- Parameters:
thePacketPool
- Packet pool.theDefaultAddress
- Default value for the edu.rit.m2mp.udp.address property, or
null if there is no default.
- Throws:
NullPointerException
- (unchecked exception) Thrown if thePacketPool is null.
M2MPInitializationException
- (unchecked exception) Thrown if the UDP channel cannot be
initialized.
receivePacket
public Packet receivePacket()
throws IOException
- Receive an M2MP packet via this channel.
- Specified by:
receivePacket
in class Channel
- Returns:
- M2MP packet that was received.
- Throws:
IOException
- Thrown if an I/O error occurred.
transmitPacket
public void transmitPacket(Packet thePacket)
throws IOException
- Send the given M2MP packet via this UDP channel.
- Specified by:
transmitPacket
in class Channel
- Parameters:
thePacket
- M2MP packet to be sent.
- Throws:
IOException
- Thrown if an I/O error occurred.
Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark@cs.rit.edu.