views:

97

answers:

2

We have a SAAS application where reporting and other print jobs are generated on our application servers and then sent to CUPS print queues. The queue prints to printers at the client sites via IP printing; so far everything works fine.

However, we have a new requirement with a new customer. They want a print job to print to the printer closest to the current workstation in use. These are a group of 8 shared workstations, each workstation has two printers near by: a laser printer and a thermal label printer. The printers are connected to the network and have their own IP address. They support IP printing.

Since a user comes in a just selects an open workstation. We can't tie printers to users. How do we identify a workstation and map its nearby printers. It's easy enough to once we id a workstation to make a database table that stored it nearby printers that we can query but how do we ID the workstation?

Cookie? What happens if they delete all the browser history? Other ideas?

A: 

Maybe I'm misunderstanding this, but from what I read as soon as you identify the workstation you can build a static map of the printers nearby? If so, why not use the IP of the workstation as an identifier. It should be straight-forward to read it from the HTTP request.

As for a bit of a more exotic solution. If your network setup is fairly formal in that those printers nearby will probably share a common router/switch, you could trace route from the SAAS server to the workstation (1) and then to each printer (2). Then matching up (1) and (2) and finding those that have the closest switch to the end IP should give you the closest printer.

So let's say workstation A and printer A are closest they are connected to switch B which over a few hops is connected to switch C and that's also where your servers are connected.

(1) should look something like this:

Hop 1: Server IP 
Hop .....
Hop 2: Switch M
Hop .....
Hop n-1: Switch A
Hop m: Workstation A

One of the routers from (2) should share the last two hops

Hop n: Switch A
Hop m: Workstation A

Therefore take a printer where m-n is the smallest number.

I would certainly go for the static IP to printer solution because it is simple, but in case that is not an option, then maybe the latter is. But this is only if the network setup is large and formal enough.

HTH Alex

AlexDuggleby
Can't get the workstation IP all we get is the external address, the customer network is NAT'ed. We figured out that the port is consistent for a session, but there is no way to map a port to what machine is active. Make sense?
Ross R
Oh ok that changes everything. I though you were on your own LAN. Let me try another answer :)
AlexDuggleby
A: 

How about using this technique to get the IP address of the client using JavaScript then sending it back to the server:

http://www.gnucitizen.org/projects/javascript-address-info/

You could then map IP to the port on the NAT and have a unique mapping. He actually describes a very similar problem to yours.

AlexDuggleby