Starting from:

$29.99

Assignment 2_The Ticket Counter

Assignment2
The Ticket Counter
Objective:
Simulate a railway ticket booking system where several ticket booking agents
(clients) simultaneously book tickets by sending requests to the central server.
Implementation Details:
Server: The server will accept multiple requests from different booking agents
(clients) and handle those requests through s elect() . The train details are as
follows:
Train
(Number/Name)
#coaches/#seats
(AC)
#coaches/#seats
(Sleeper)
Available Berth
Types
12321/Superfast Exp 3(A1
to A3)/
72 12(S1
to S12)/
72 SU, SL, UB, MB, LB
12301/Rajdhani Exp 13(A1
to A13)/
54 SU,
SL, UB, LB
SU: Side Upper, SL: Side Lower, UB: Upper Berth, MB: Middle Berth, LB: Lower Berth
The server will allot the berths according to the preferences (if provided in the
client’s request) or in the continuous fashion (if the preference is not provided).
Note that the berth allocation can be extended to the next coach if required.
Berth allotment in the same coach for a booking should have higher priority over
berth preference. If there are no berths available then server should return
“Sorry! no berths available!”.
Also, their is no provision for partial booking i.e. for a request, either all the berths
will be booked or none. If the booking is successful, then server will return the
coach number and the berth numbers allotted (you can follow your own format
for response).
A policy need to be defined by server while processing multiple simultaneous
request use
timestamp to resolve this.
The server will have an option (press a button, say ‘1’) to display the current
booking status of all the trains. To implement this, server has to f ork() a separate
child process. Details should be displayed in the following tabular format:
Train #seats
Total[Booked/Available]
(AC)
#seats
Total[Booked/Available]
(Sleeper)
Superfast Exp 216[132/84] 864[487/377]
Rajdhani Exp 702[702/0] Booking
Agent: The booking agent will read the booking details from a . csv
(comma separated values) file where every line is a separate booking request.
The booking agent will wait for a fixed period of time (5 seconds) after every
booking request. The format of booking file is as follows:
Passenger
ID
Train Coach Type #berths Preferences Ages of
Passengers
1 12321 AC 4 SLSULBLB
17432278
2 12321 Sleeper 2 SUUB
2824
3 12301 AC 1 NA 23
*Here NA signifies no preferences and the preferences and ages are separated by hyphen ()
After getting the response from the server the booking agent will write that
response into another . csv file containing 2 columns Passenger
ID and server
response.
Implement at least three booking agents and a server to simulate “ The Ticket
Counter”.
Tasks:
(a). Implement a server
(b). Implement booking agent process.
(c). Berth allocation policy
(d). Display system in server
(e) Prioritize booking which has (i). more number of passengers and (ii). more
number of senior citizens. Design a policy keeping the above two in mind state
clearly the policy implemented.
Consider all sockets as TCP sockets

More products