首页 > > 详细

data编程辅导、Java,Python程序辅导

IBR-Chat
In this task a simple chat application called IBRC (IBR Chat) is to be developed. Chats can take place in
IBRC in two different ways. First, direct messages can be sent to any other user. Secondly, a user can
join any number of groups to communicate with other users in the same group. IBRC shall use a
client-server model.
In the following, the basic concepts of IBRC are briefly explained before the tasks are presented in detail.
Clients
Each client maintains a connection to exactly one server. All data the client has entered is sent to this
server. The server must then decide on their further processing of the data. Clients are identified by the
name of the corresponding computer (host name). The participants are not identified by their real
names, but by so-called nicknames, which they can freely choose. These nicknames can be up to nine
characters long and must consist of letters or numbers.
Server
Servers essentially fulfill two tasks. On the one hand, they receive all data from the connected clients in
order to forward or process them. The participants (in the form of clients) therefore never communicate
directly with each other, but always via one or more servers. On the other hand, each server must
manage information about the clients in the network. This is necessary, among other things, to
maintain control over all existing users or groups (for a description of the groups see next section). For
example, it must be prevented that two groups or clients get the same name. More details about the
communication process are given in the section Communication
Groups
In a group, users can join together to exchange messages. A user’s messages are sent to all users who
belong to the group. If the very first user joins a group, i.e. if the group does not yet exist, it will be
created. It is important to note that the state of a group can change dynamically, for example when new
users join. This change must be noticed by the corresponding server and the necessary information
must be sent to and synchronized with all other servers in the network.
Groups are identified by short names, e.g. “birthday planning”. These identifiers are max. 32 characters
long and must be unique, i.e. there must not be two groups (or even user) with the same name. The
identifiers are used for all commands to uniquely identify the group. For example, to join the group
“birthday planning”, a user must enter the command JOIN birthday planning.
In addition, there is a more detailed description (topic) of the discussed content for each group. For
example, the topic of the “Birthday Planning” group could be: “How much should the group gift cost?”
The topic can only be set by the user who created the group. However, it is also possible to change it
later. The right to change the topic is not transferable to other users.
Commands
Commands are line-based, i.e. after pressing the Return key the current line is sent to the connected
server. They are used to control communication for users, e.g. to join a group, obtain information
about other users, etc. They are identified by a preceding slash (“/”), and are not case-sensitive. All
commands have the form [ [ ]]. An overview of all IBRC
commands is given in the following table:
Command Description
JOIN Join a group
LEAVE Leave the group
NICK Change own nickname
LIST List all existing groups
GETTOPIC Prints the current topic of the group
SETTOPIC Sets the current topic of the group
MSG Message a single user or group
QUIT Leave IBRC
Communication
In IBRC, two users(clients) are never directly connected to each other, but always via one or more servers.
A client is always connected to exactly one server. The servers have to take care that a message sent in
a group is forwarded to all users of this group. It is important that the client sends the message only
once to the connected server (even if there are other clients connected to the server that belong to the
group). The server decides to which clients and if necessary to which other servers the message has to
be forwarded. Of course, the message is only sent to those servers that need the message in order to
send it to other clients belonging to the corresponding group.
In addition, the servers are responsible for processing the commands that the users can enter. This
requires the storage of data on all existing users, groups, etc. It is important that all servers in the
network synchronize their data, i.e. that all servers always have the same data. It is clear that this
requires communication between the servers. It is up to the participants to decide how to implement
the server communication.
Network Topology
The IBRC network, consisting of clients and servers, should have a tree structure and is therefore cyclefree.
The exact topology can be freely chosen by the participants. However, it must be possible to
integrate at least five servers and 10 clients into the network. The required cycle freedom can be
ensured by the fact that new servers may only connect to an already existing server.
If the server topology is fixed, clients may connect to any server, whereby a client may of course only be
connected to one server. After the first client has been integrated into the network, the topology for the
servers is fixed, i.e. no connections between servers may be created or removed. Inserting new servers
is also no longer allowed. It can be assumed that there will never be more than 10 servers and 20 clients
(i.e. arrays can be used for storage).
Communication
There are two different types of communication in IBRC: one-to-many und one-to-one. Both types
require the use of the MSG command.
• one-to-many: This form of communication corresponds to the group-based form, i.e. the messages
are sent to all users in a group.
• one-to-one: A communication between exactly two users takes place.
Input Validation
before processing requests, the servers have to validate them in the first place. Furthermore, clients
also validate incoming messages from the connected server.
Implementation
Requirements:
In this task a small IBRC network with several servers shall be implemented. The network must be able
to manage at least five servers and 10 clients. The required topology was already described in network
topology.
The servers receive data from the connected clients using the protocol specified above. If messages are
involved, they must be sent to the corresponding client(s). If a client is not directly accessible from the
Server, the message must be “routed”, i.e. sent to the server from which the client can be reached.
Since the topology used is cycle-free, these routing decisions are unambiguous. It must be ensured
that only those servers that really need the message receive it. A “broadcast” of messages from each
server to all others to save routing is not allowed. TCP must be used as the transport protocol.
To control which message a server receives and to whom it forwards it, a simple output must be
implemented on each server, which contains the host names of the sender and the addressee and the
next-hops for each received message.
Necessary Commands
All commands listed in the following description must be implemented. Once again, it should be remembered
that commands must be preceded by a slash when they are entered. Spaces at the beginning,
in the middle (between individual arguments) or at the end of a command should be ignored.
JOIN
With the help of this command a user joins a group. Name isthe short name of the group (e.g. “birthday
planning”). If the group does not yet exist, it will be created.
LEAVE
Hereby the user leaves the group with the given name. If the user is the last member of the group, the
group is deleted.
NICK
Sets the nickname of the user under which the user will appear. These names can be chosen freely, but
no two users may have the same name. Nicknames are up to nine characters long and must consist of
letters or numbers. Incorrect entries are acknowledged with an error message.
LIST
Lists all groups existing in IBRC with their short names.
GETTOPIC
Outputs the detailed description (topic) for the specified group. If the group does not exist, an error
message is displayed.
SETTOPIC
Sets the topic of the specified group. This command can only be executed by the user who created this
group. Any attempt by other users to execute this command will be acknowledged with a
corresponding error message.
MSG
Sends a message to the user or group specified in . If the specified user or group does not
exist, an error message is displayed.
QUIT
If a user wants to end the client, he can do so with this command. If he still belongs to groups, membership
in groups is automatically terminated.

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!