take a look at this pic...height and width give you the area (square inches) of port...the length adjust tuning for a given port area.
length is suppose to be measured down the middle of the box indicated by the red line...
there is also something called 'end correction' which equates to half the ports width
if you are using a box wall as part of the port, as illustrated in the below pic, then the port actually becomes longer than it physically is
so physical length + end correction = effective length of the port
the volume the port takes up inside the box also need to be subtracted from the box volume when calculating frequency...its like a giant loop equation....when u adjust port length, it adjust the box's net volume, which in turn adjust the tuning..